class Suite(object): pass
class Heart(Suite): pass
class Club(Suite): pass
etc.
A class in python is an object. So you can write
x=Heart
etc.
snakile
2010-07-14 17:45:00
class Suite(object): pass
class Heart(Suite): pass
class Club(Suite): pass
etc.
A class in python is an object. So you can write
x=Heart
etc.
here is very same popular question on stackoverflow
Edit:
class Suite(set):
def __getattr__(self, name):
if name in self:
return name
raise AttributeError
s1 = Suite(['Heart', 'Club', 'Spade', 'Diamond'])
s1.Heart