[Python-Dev] PEP 340 -- loose ends
Shane Hathaway
shane at hathawaymix.org
Thu May 5 06:51:17 CEST 2005
Greg Ewing wrote:
> Shane Hathaway wrote:
>
>>For each block statement, it is necessary to create a *new* iterator,
>>since iterators that have stopped are required to stay stopped. So at a
>>minimum, used-defined statements will need to call something, and thus
>>will have parentheses.
>
>
> Not necessarily!
>
> class Frobbing:
>
> def __neg__(self):
> begin_frobbing()
> try:
> yield
> finally:
> end_frobbing()
>
> frobbing = Frobbing()
>
> ...
>
> -frobbing:
> do_something()
Larry Wall would hire you in a heartbeat. ;-)
Maybe there's really no way to prevent people from writing cute but
obscure block statements. A keyword like "block" or "suite" would give
the reader something firm to hold on to.
Shane
More information about the Python-Dev
mailing list