for loop possible enhancement
Dan Schmidt
dfan at harmonixmusic.com
Fri Sep 22 14:54:28 EDT 2000
More information about the Python-list mailing list
Fri Sep 22 14:54:28 EDT 2000
- Previous message (by thread): for loop possible enhancement
- Next message (by thread): for loop possible enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
bob van der Poel <bvdpoel at uniserve.com> writes: | Playing with some for/next loops I find that having something like | | for a,b in [[1,2],[3,4],[4,5]]: | ... | | works nicely. However, what would be more useful at times is the | possiblity to: | | for a,b in [[1,2,3,4], [a,b,c,d]]: | | which, intutively(?) would set a to the value 1 and b to 'a', etc. You can do this now with the slightly unwieldy map (None,...) idiom: for a, b in map (None, [1,2,3,4], [5,6,7,8]): or, in Python 2.0, which is currently in beta, so if you don't want be tantalized by features that are available only in beta releases stop reading now, you can use the 'zip' builtin function: for a, b in zip ([1,2,3,4], [5,6,7,8]): -- Dan Schmidt | http://www.dfan.org Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html
- Previous message (by thread): for loop possible enhancement
- Next message (by thread): for loop possible enhancement
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list