Created
October 16, 2010 20:06
-
-
Save mashiro/630219 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import inspect | |
def envs(func): | |
def inner(*args, **kwargs): | |
frame = inspect.stack()[1][0] | |
kwargs.update(dict(locals=frame.f_locals, globals=frame.f_globals)) | |
return func(*args, **kwargs) | |
return inner | |
@envs | |
def test(**kwargs): | |
print kwargs['locals'] | |
class Test(object): | |
@envs | |
def __init__(self, **kwargs): | |
print kwargs['locals'] | |
def main(): | |
thisis = 'local variable' | |
test() | |
t = Test() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment