About 520,000 results
Open links in new tab
  1. 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" ...

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

    Sep 16, 2008 · Yes, definitely possible to write static variables and methods in python. Static Variables : Variable declared at class level are called static variable which can be accessed directly using class …

  3. python class instance variables and class variables

    Feb 23, 2016 · I'm having a problem understanding how class / instance variables work in Python. I don't understand why when I try this code the list variable seems to be a class variable class testClass(): ...

  4. python - How can I access "static" class variables within methods ...

    In java, an entire class is compiled, making the namespace resolution real simple: any variables declared outside a method (anywhere) are instance (or, if static, class) variables and are implicitly …

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

    117 When you write a class block, you create class attributes (or class variables). All the names you assign in the class block, including methods you define with def become class attributes. After a …

  6. python - How do I set and access attributes of a class? - Stack Overflow

    Well, Python tries to get first the object variable, but if it can't find it, will give you the class variable. Warning: the class variable is shared among instances, and the object variable is not.

  7. looping over all member variables of a class in python

    How do you get a list of all variables in a class thats iteratable? Kind of like locals (), but for a class

  8. oop - Variable scopes in Python classes - Stack Overflow

    Class variables can be modified by referring to them by class name (e.g. Class.x = 5) and all instances will inherit these changes. Instance variables are private to an instance and can only be modified by …

  9. What is the naming convention in Python for variables and functions ...

    39 As mentioned, PEP 8 says to use lower_case_with_underscores for variables, methods and functions. I prefer using lower_case_with_underscores for variables and mixedCase for methods and …

  10. difference between variables inside and outside of __init__() (class ...

    Oct 8, 2009 · I would like to add something to the responses that I read in this thread and this thread (which references this one). Disclaimer: this remarks come from the experiments I ran Variables …