Need help with Python scoping rules
no.email at please.post
Wed Aug 26 22:16:54 CEST 2009
In <7figv3F2m3p0dU1 at mid.uni-berlin.de> "Diez B. Roggisch" <deets at nospam.web.de> writes:
>But if you insist on the above methodology, you can do this:
> def fact(n):
> def inner(n):
> if n < 2:
> return 1
> return n * inner(n - 1)
> return inner(n)
> _classvar = fact(5)
>This makes inner a *local* variable, which is found.
Thanks for this. I think this is the most straightforward workaround.
More information about the Python-list