Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Enum (tuple):
- def __getitem__(self, key):
- super(Enum, self).__getitem__(key)
- def __init__(self, *iterable):
- id = 1
- self.vals = {}
- keys = []
- for it in iterable:
- for val in it:
- self.vals[id]=val
- keys.append(id)
- id <<= 1
- super(Enum, self).__init__(keys)
- def __str__(self):
- return super(Enum, self).__str__()
- def main():
- e = Enum(['first','dfdf','rt'])
- print e[0]
- print type(e)
- print e
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement