[Tutor] a query
alan.gauld@bt.com
alan.gauld@bt.com
Mon, 12 Aug 2002 18:12:54 +0100
> def A():
> ----def B():
>
> def C():
> ----# how can i call B() from here.
>
> is it possible in python?
Not unless A returns B as a value.
Python correctly implements B within A's namespace so
you can only call B within A. If B was supposed to
be accessible outside A it should have been declared
there - and if not there's probably a good reason for
not declaring it externally - subtle side-effects
for example. (Otherwise somebody was just being
stupid and should have declared it globally...!)
In general Python does the "right thing", then provides
a way to do the wrong thing if you really really must...
like accessing the underlying dictionaries etc...
Alan g.