How can I refer to class variable in a function without referring to its class in Python?
Posted
by Alex B
on Stack Overflow
See other posts from Stack Overflow
or by Alex B
Published on 2010-05-28T02:34:18Z
Indexed on
2010/05/28
2:41 UTC
Read the original article
Hit count: 216
python
I have a following class:
class Foo:
CONSTANT = 1
def some_fn(self):
a = Foo.CONSTANT
# do something
How can I refer to Foo.CONSTANT
without referring to Foo
, or refer to Foo
in a generic way? (I don't want to change all references to it when renaming a class)
© Stack Overflow or respective owner