Python Module identifies as dict -


lets have lot of key-pair data. have data in package can imported. there way make modules work dicts, performance , extendibility reasons?

example:

common/pairs/  ├── buildings.py  └── __init__.py  import buildings  buildings["foo"] == "bar" 

note: desired result can archived putting declaring buildings in __init__.py compiled every time, not drag , undroppable, , seems ugly.

is there way achieve well? there way achieve @ all?

not recommend it, can assign dict sys.modules. python doesn't care what's there module object.

# buildings.py sys import modules if __name__ != "__main__":     modules[__name__] = {'a': 1, 'b': 2, ...} 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -