Created
December 19, 2012 09:05
-
-
Save yueyoum/4335445 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#不用传参的key | |
static_one = 'o.nimei.xxx' | |
# 需要参数的key | |
player = lambda p: 'player.{0}.info'.format(p) | |
player_levels = lambda p, lv: 'player.{0}.{1}'.format(p, lv) | |
if __name__ == '__main__': | |
# 每次增加新key后, 运行本文件,检查是否有key重名 | |
__all_keys = globals() | |
__all_keys_str = [] | |
from types import FunctionType as __FunctionType | |
from inspect import getargspec as __getargspec | |
for k, v in __all_keys.items(): | |
if k.startswith('__'): | |
continue | |
if isinstance(v, __FunctionType): | |
args_count = len(__getargspec(v).args) | |
args = [0 for i in range(args_count)] | |
v = v(*args) | |
if v in __all_keys_str: | |
raise Exception("Duplicate key: %s" % v) | |
__all_keys_str.append(v) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment