Alternative iterator syntax
Michael Hudson
mwh21 at cam.ac.uk
Wed Feb 21 14:34:59 EST 2001
More information about the Python-list mailing list
Wed Feb 21 14:34:59 EST 2001
- Previous message (by thread): Alternative iterator syntax
- Next message (by thread): Alternative iterator syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Tim Hochberg" <tim.hochberg at ieee.org> writes: [schnipp] > I don't think this will work right though. Consider: > > for k in aUserDict.keys: > # Do some stuff > for k in aUserDict.keys: > # Do some more stuff > > The way this is implemented here the second loop would bail out > immediately because there is only a single iterator for a given > instance and it is already exhausted. Nah, reset the allocator every time item 0 is asked for. I'd have to admit I haven't read Huaiyu Zhu's proposal carefully enough to be sure this would work, but something like this ought to be possible, I'd have thought. I mean, l = range(10) for i in l: # do some stuff for i in l: # do some other stuff will have to do something along these lines, no? Cheers, M. -- In general, I'd recommend injecting LSD directly into your temples, Syd-Barret-style, before mucking with Motif's resource framework. The former has far lower odds of leading directly to terminal insanity. -- Dan Martinez
- Previous message (by thread): Alternative iterator syntax
- Next message (by thread): Alternative iterator syntax
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list