http://qiita.com/natsutan/items/90a2d1a005cfe9afe017
It's nothing to write a reply to an article four years ago, so I'll write it here
Well, I don't think you need this kind of const,
If the dictionary doesn't work, there is a way to write that you should use tuples.
class Consts:
__slots__ = ()
@property
def spam(self):
return 1
@property
def ham(self):
return 2
c = Consts()
print c.spam, c.ham
c.egg = 3 # AttributeError: 'Consts' object has no attribute 'egg'
Recommended Posts