question about for cycle
Duncan Booth
duncan.booth at invalid.invalid
Mon Oct 1 03:46:32 EDT 2007
More information about the Python-list mailing list
Mon Oct 1 03:46:32 EDT 2007
- Previous message (by thread): Python and SSL
- Next message (by thread): Function return a dictionary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"fdu.xiaojf at gmail.com" <fdu.xiaojf at gmail.com> wrote: >>> Sometime it maybe a waste to generate all possible combinations of >>> i,j first. >> >> It doesn't; read about generator expressions at >> http://www.python.org/dev/peps/pep-0289/ >> >> George >> > Thanks, I didn't realize that. > > However, I still think labeled break and continue is a valuable > feature, which is easier to understand and to use. > Can you come up with a realistic example where you think a labelled break would be easier to understand and use? A concrete example would really help if you hope to persuade anyone that your way is better. I find that Python's ability to extract the control part of a loop into a generator is an extremely powerful way to make loops much clearer for several reasons: you separate completely the 'what we are looping over', and 'when do we stop' from the 'what do we then do with each item'; also you have an opportunity to give the code controlling the loop a separate (and meaningful) name.
- Previous message (by thread): Python and SSL
- Next message (by thread): Function return a dictionary
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list