Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class EnumMeta:
- def __init__(cls, className, inherits, dict):
- cls.__class__.__name__ = inherits[0].__class__.__name__ \
- if inherits \
- else className
- cls.__dict__ = dict
- def __iter__(cls):
- for key in cls.__dict__:
- if not key.startswith('__'):
- yield cls.__dict__[key]
- def __contains__(cls, item):
- return item in cls.__iter__()
- def __call__(cls, *args, **kwargs):
- return cls.list()
- def dict(cls):
- result = dict()
- for key in cls.__dict__:
- if not key.startswith('__'):
- result[key] = cls.__dict__[key]
- return result
- def list(cls):
- return list(cls.__iter__())
- class Enumeration:
- __metaclass__ = EnumMeta
- class ThrowTypes(Enumeration):
- (GRENADE_F1, HOMEMADE_GRENADE, ATOMIC_GRENADE, STONE,
- TEST_CREATURE_GRENADE, BIO, OUTCAST, RGD5_GRENADE,
- F1_FAKE_GRENADE, RGN_GRENADE, RGO_GRENADE, MINE, SNOW_GRENADE,
- FLASH_GRENADE, WEB_GRENADE, POISON_GRENADE, GLUE_GRENADE,
- HOMEMADE_ACID_GRENADE, SMOKE_GRENADE, YETI, SPIDER_WEB, STONE_GW, SPORES_GRENADE,
- HOMEMADE_MINE) = xrange(24)
- print ThrowTypes
- print ThrowTypes.GRENADE_F1, ThrowTypes.RGO_GRENADE
- for T in ThrowTypes:
- print T
- print 5 in ThrowTypes
- print ThrowTypes.dict()
- print 'SMOKE_GRENADE' in ThrowTypes.dict()
Advertisement
Add Comment
Please, Sign In to add comment