About 29,300,000 results
Open links in new tab
  1. python - Call Class Method From Another Class - Stack Overflow

    class A(object): def method1(self, a, b, c): # foo method = A.method1 method is now an actual function object. that you can call directly (functions are first class objects in python just like in …

  2. How do I type hint a method with the type of the enclosing class?

    class Position: def __init__(self, x: int, y: int): self.x = x self.y = y def __add__(self, other: Position) -> Position: return Position(self.x + other.x, self.y + other.y) But my editor (PyCharm) says that …

  3. python - What is the meaning of single and double underscore …

    Double Underscore (Name Mangling) From the Python docs: Any identifier of the form __spam (at least two leading underscores, at most one trailing underscore) is textually replaced with …

  4. python - How to make a class property? - Stack Overflow

    In python I can add a method to a class with the @classmethod decorator. Is there a similar decorator to add a property to a class? I can better show what I'm talking about. class …

  5. python - Calling parent class __init__ with multiple inheritance, …

    Because of the way diamond inheritance works in python, classes whose base class is object should not call super().__init__(). As you've noticed, doing so would break multiple inheritance …

  6. python - What is the purpose of the `self` parameter? Why is it …

    A class (instance) method has to be aware of it's parent (and parent properties) so you need to pass the method a reference to the parent class (as self). It's just one less implicit rule that you …

  7. oop - What are metaclasses in Python? - Stack Overflow

    In Python, a class specifies how the class's instance will behave. Since metaclasses are in charge of class generation, you can write your own custom metaclasses to change how classes are …

  8. oop - How do I implement interfaces in python? - Stack Overflow

    238 Implementing interfaces with abstract base classes is much simpler in modern Python 3 and they serve a purpose as an interface contract for plug-in extensions. Create the …

  9. How do I get list of methods in a Python class? - Stack Overflow

    How do I get a list of class methods? Also see: How can I list the methods in a Python 2.5 module? Looping over a Python / IronPython Object Methods Finding the methods an object …

  10. correct way to define class variables in Python - Stack Overflow

    I noticed that in Python, people initialize their class attributes in two different ways. The first way is like this: class MyClass: __element1 = 123 __element2 = "this is Africa" ...