How to create a limited set of instanceses of a class
Alex Martelli
aleax at mac.com
Sun Jul 2 16:26:28 EDT 2006
madpython <madpython at gmail.com> wrote:
> Thanks, Alex, again. The lesson has been taught. I appreciate very much
> you spent time trying to help. Indeed the culprit of that infrequent
> infinite loops was that bound reference "item" in the printing
> loop. But frankly i thought that it only existed inside that loop.
> Apparently I was wrong and glad that it was revealed.
Right -- a loop per se (be it a while loop or a for loop), just like an
if statement or a try statement, is NOT a separate scope from the code
around it (neither is a list comprehension); _functions_ are separate
scopes, and so are genexps.
Alex
More information about the Python-list
mailing list