trsqxyz / tips

Tips are here.
The Unlicense
0 stars 0 forks source link

ローカルの名前空間とそれぞれの値をタプルで取得する #1

Open trsqxyz opened 10 years ago

trsqxyz commented 10 years ago

[(k,v) for k, v in locals().items() if not k[:2] == '__' ]

builtin も取得したいときは if文を消すと全部でてくる

rf.

https://sites.google.com/site/diveintopythonjp/home/8-htmlshori/8-5-locals-to--globals

trsqxyz commented 10 years ago

if 文を消さなくても locals() だけで出る

trsqxyz commented 10 years ago

vars() でローカル変数の辞書が取得できる