On Fri, Apr 29, 2005, Nick Coghlan wrote: > > If you want to emphasise the similarity, the following syntax and > explanation is something that occurred to me during lunch today:
We don't want to emphasize the similarity. > Python offers two variants on the basic iterative loop. > > "for NAME from EXPR:" enforces finalisation of the iterator. At loop > completion, a well-behaved iterator is always completely exhausted. This > form supports block management operations, that ensure timely release of > resources such as locks or file handles. > If the values being iterated over are not required, then the statement > may be simplified to "for EXPR:". > > "for NAME in EXPR:" skips the finalisation step. At loop completion, a > well-behaved iterator may still contain additional values. This form allows > an iterator to be consumed in stages. -1 -- the Zen of Python implies that we should be able to tell which construct we're using at the beginning of the line. -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "It's 106 miles to Chicago. We have a full tank of gas, a half-pack of cigarettes, it's dark, and we're wearing sunglasses." "Hit it." _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com