For business logic reasons I want to be able to create an object that has an attribute named global
. But I obviously can't just do
class Foo(object):
def __init__(self):
self.global = True
Because global
is a reserved keyword that has special meaning in Python. Dynamically getting the attribute using __getattr__
or __getattribute__
has the same problem though. Is there anyway that I can do this, or do I have to make the attribute name global_
?
I need to be able to access the attribute directly from the object, so I can't use getattr(foo, 'global')
.