Advertisement
maurobaraldi

Python inspect example

Aug 27th, 2013
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import inspect
  4.  
  5. def info(msg):
  6.     frm = inspect.stack()[1]
  7.     mod = inspect.getmodule(frm[0])
  8.     print '[%s] %s' % (mod.__name__, msg)
  9.  
  10. def call_a():
  11.     info('from call_a')
  12.  
  13. def call_b():
  14.     info('from call_b')
  15.  
  16. if __name__ == '__main__':
  17.     call_a()
  18.     call_b()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement