About 109,000 results
Open links in new tab
  1. class - Types and classes in Python - Stack Overflow

    Specifically read the section on classes and the difference between new style and classic classes. Try typing the following into your REPL: class A: pass class B(object): pass and you'll see that …

  2. type of class in python - Stack Overflow

    Oct 7, 2010 · New-style classes were introduced in Python 2.2 to unify classes and types. A new-style class is neither more nor less than a user-defined type. If x is an instance of a new-style …

  3. python - How to force/ensure class attributes are a specific type ...

    Mar 29, 2020 · In Python, primitive data types (int, float, str, booleans) are themselves classes. Thus if you instantiate the class attributes of your class before passing the method parameters …

  4. Class vs. Type in Python - Stack Overflow

    Mar 12, 2016 · Starting with Python 2.2, the developers of Python have slowly moved towards unifying the two concepts, with the difference all but gone in Python 3. Built-in types are now …

  5. How to compare two classes/types in python? - Stack Overflow

    Python uses the concept of metaclasses, which are basically "classes of classes". That means, even a Class is an object in Python, which has its own class - accessible using the type in …

  6. python - What are data classes and how are they different from …

    T. Hunner's talk on Easier Classes: Python Classes Without All the Cruft; Python's documentation on hashing details; Real Python's guide on The Ultimate Guide to Data Classes in Python 3.7; …

  7. python - Type hints with user defined classes - Stack Overflow

    This feature is available in python 3.9+, and also in 3.7+ if using from __future__ import annotations. In terms of this specific question, it means that instead of from typing import …

  8. Elegant ways to support equivalence ("equality") in Python classes

    Python 3 has only new-style classes that are declared as class A:, class A(object): or class A(B):. For classic-style classes, a comparison operation always calls the method of the first operand, …

  9. python - Do Cython extension types support class attributes?

    Feb 27, 2015 · Just declare them as you would declare them in Python: cdef class Foo: bar = 4 The generated code shows that these static attributes are stored as Python objects in the …

  10. Generics/templates in python? - Stack Overflow

    Oct 13, 2014 · Thus, multiple classes inheriting List( str ) as a parent would be inheriting from two separate classes. To overcome this, you need to create a dict to store the various forms of the …

Refresh