Skip to content

Instantly share code, notes, and snippets.

@girish
Forked from mashiro/env.py
Created October 18, 2010 07:25
Show Gist options
  • Save girish/631862 to your computer and use it in GitHub Desktop.
Save girish/631862 to your computer and use it in GitHub Desktop.
#!/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