[Tutor] Accessing callers context from callee method

Chris Rebert clp2 at rebertia.com
Tue Feb 24 19:56:36 CET 2009


On Tue, Feb 24, 2009 at 10:53 AM,  <mobiledreamers at gmail.com> wrote:
> when i call a method foo from another method func. can i access func context
> variables or locals() from foo
> so
> def func():
>   i=10
>   foo()
>
> in foo, can i access func's local variables on in this case i

You can, but it's an evil hack that I would avoid if at all possible;
there are almost certainly better ways to accomplish whatever your
goal is.

Cheers,
Chris

-- 
Follow the path of the Iguana...
http://rebertia.com


More information about the Tutor mailing list