Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. outerLocal = "foo"
  2.  
  3. def innerMethod(innerParam):
  4. # locals() will not work here
  5. print("%(outerParam)s %(outerLocal) %(innerParam)" %locals())
  6.  
  7. >>> def foo(var):
  8. ... car=3
  9. ... print '%(var)s %(car)s' % locals()
  10. ...
  11. >>> foo(123)
  12. 123 3
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement