Use self.__class__.classAttr
. This should work for both old & new style classes.
More Related Contents:
- What are metaclasses in Python?
- Static class variables and methods in Python
- What is the purpose of the word ‘self’?
- What is the meaning of single and double underscore before an object name?
- Usage of __slots__?
- Using property() on classmethods
- Why do you need explicitly have the “self” argument in a Python method?
- How can I create a copy of an object in Python?
- Why does Python code use len() function instead of a length method?
- Iterate over object attributes in python [duplicate]
- Python – Classes and OOP Basics
- Difference between methods and functions, in Python compared to C++
- How to avoid infinite recursion with super()?
- List all base classes in a hierarchy of given class?
- Why is `object` an instance of `type` and `type` an instance of `object`?
- Understanding the difference between __getattr__ and __getattribute__
- Difference between methods and attributes in python
- Using the __call__ method of a metaclass instead of __new__?
- Python: how to “kill” a class instance/object?
- What is the purpose of the `self` parameter? Why is it needed?
- difference between variables inside and outside of __init__() (class and instance attributes)
- @classmethod vs @staticmethod in Python
- What is the purpose of static methods? How do I know when to use one? [duplicate]
- Is there a benefit to defining a class inside another class in Python?
- How to assign a new class attribute via __dict__?
- What are the consequences of nesting classes? [closed]
- Should I use a class or dictionary?
- In Python, when are two objects the same?
- How to replace an instance in __init__() with a different object?
- Type Hinting for objects of type that’s being defined [duplicate]