About 51 results
Open links in new tab
  1. python - Differences between `class` and `def` - Stack Overflow

    What is the main difference between class and def in python? Can a class in python interact with django UI (buttons)?

  2. How do I declare custom exceptions in modern Python?

    How do I declare custom exception classes in modern Python? My primary goal is to follow whatever standard other exception classes have, so that (for instance) any extra string I include in the exc...

  3. What is the purpose of the `self` parameter? Why is it needed?

    First off, methods belong to either an entire class (static method) or an object (instance) of the class (object method). When calling a static method in Python, one simply writes a method with regular …

  4. How can I define a class in Python? - Stack Overflow

    Quite simple, I'm learning Python, and I can't find a reference that tells me how to write the following: public class Team { private String name; private String logo; private int m...

  5. class - Understanding Python super () with __init__ () methods - Stack ...

    Feb 23, 2009 · In Python 2, we were required to call super like this with the defining class's name and self, but we'll avoid this from now on because it's redundant, slower (due to the name lookups), and …

  6. oop - What do __init__ and self do in Python? - Stack Overflow

    Jul 8, 2017 · class A(object): def __init__(self): self.x = 'Hello' def method_a(self, foo): print self.x + ' ' + foo ... the self variable represents the instance of the object itself. Most object-oriented languages …

  7. 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 …

  8. How does the @property decorator work in Python?

    Functions in Python are first-class objects which means that they can be referenced by a variable, added in the lists, passed as arguments to another function, etc.

  9. python - How can I separate the functions of a class into multiple ...

    Here is how I do it: Class (or group of) is actually a full module. You don't have to do it this way, but if you're splitting a class on multiple files I think this is 'cleanest' (opinion). The definition is in …

  10. Python class definition syntax - Stack Overflow

    6 A class definition is a bit different from a function/method definition. The parentheses in class definitions are for defining from which class you inherit. You don't write def in front of it, and when …