![]() |
|
Keep It Simple, Stupid | |
PerlMonks |
comment on |
( #3333=superdoc: print w/replies, xml ) | Need Help?? |
Yes, Python doesn't have block scopes.
It has 4 scope levels° - it took me a while to understand them - and function scope is the smallest. To mimic something similar to blocks you'll need again a named function in Python, since "lambdas" (aka anonymous subs in Perl) are limited to one statement only. Python compensates it by allowing nested named functions, leading to enclosed scope. * > push @out, {A => $one, b => $two} while my ($one, undef, $two) = some_function()) This is certainly not doing what you expect, those $one and $two variables are different.
Please keep in mind that declarations are only effective for following statements.
Cheers Rolf °) Local, Global, Built-in, Enclosed
UPDATE*) remember Py's mantra about "explicit is better than implicit"? Perl's scoping rules are explicit ones here (and easier to understand) In reply to Re^4: A short whishlist of Perl5 improvements leaping to Perl7
by LanX
|
|