writable iterators?
Thomas 'PointedEars' Lahn
PointedEars at web.de
Wed Jun 22 19:30:13 EDT 2011
Mel wrote:
> Steven D'Aprano wrote:
>> I *guess* that what you mean by "writable iterators" is that rebinding e
>> should change seq in place, i.e. you would expect that seq should now
>> equal [42, 42]. Is that what you mean? It's not clear.
>>
>> Fortunately, that's not how it works, and far from being a "limitation",
>> it would be *disastrous* if iterables worked that way. I can't imagine
>> how many bugs would occur from people reassigning to the loop variable,
>> forgetting that it had a side-effect of also reassigning to the iterable.
>> Fortunately, Python is not that badly designed.
>
> And for an iterator like
>
> def things():
> yield 1
> yield 11
> yield 4
> yield 9
>
> I don't know what it could even mean.
<http://docs.python.org/reference/simple_stmts.html#the-yield-statement>
You could have tried to debug.
Please trim your quotes to the relevant minimum.
--
PointedEars
Bitte keine Kopien per E-Mail. / Please do not Cc: me.
More information about the Python-list
mailing list