About 50 results
Open links in new tab
  1. python - Meaning of @classmethod and @staticmethod for a beginner ...

    Here we have __init__, a typical initializer of Python class instances, which receives arguments as a typical instance method, having the first non-optional argument (self) that holds a reference to a …

  2. Python __class__ () - Stack Overflow

    The parent-child relationships of the Python type system must stop somewhere, and type is that point. In your example, a.__class__ is a reference to the Foo class.

  3. class - What is the difference between objects and classes in Python ...

    I was wondering what is the difference between objects and classes in python? I thought all classes are objects, but in that case, author wouldn't have used phrase "classes and objects".

  4. What is the difference between @staticmethod and @classmethod in …

    Sep 26, 2008 · What is the difference between a method decorated with @staticmethod and one decorated with @classmethod?

  5. python - What is the difference between class and instance attributes ...

    class B(object): def __init__(self, foo=5): self.foo = foo If you're creating a lot of instances, is there any difference in performance or space requirements for the two styles? When you read the code, do you …

  6. python - How can I call a function within a class? - Stack Overflow

    I have this code which calculates the distance between two coordinates. The two functions are both within the same class. However, how do I call the function distToPoint in the function isNear? class

  7. python - Class (static) variables and methods - Stack Overflow

    Sep 16, 2008 · See what the Python tutorial has to say on the subject of classes and class objects. @Steve Johnson has already answered regarding static methods, also documented under "Built-in …

  8. When should I be using classes in Python? - Stack Overflow

    Oct 12, 2015 · In python the simple heuristic for when you should use a class comes down to whether or not your abstraction needs to be concerned with state. Abstractions that carry mutable state should …

  9. python - Getting the class name of an instance - Stack Overflow

    Feb 4, 2009 · How do I find out the name of the class used to create an instance of an object in Python? I'm not sure if I should use the inspect module or parse the __class__ attribute.

  10. python - How to print instances of a class using print ... - Stack Overflow

    A simple decorator @add_objprint will help you add the __str__ method to your class and you can use print for the instance. Of course if you like, you can also use objprint function from the library to print …