i agree with everyone above, kent, alan, roel... in fact, i have do a doubletake everytime i write code like this and have to look things up and/or play with some sample code as you all have done, just to make sure i got it working. (kinda reminds of going back to look at a perl script i wrote... have to check with the camel book to figure out what i really did.)
i like alan's idea of splitting up the loops onto different lines so that you can more clearly see the loops. the syntax does support it altho it seems kind of clunky as: print\ [ j for i in a for j in f(i) ] originally, i thought that this would work: print [j for j in [f(i) for i in a]] but then realized that because of the inner grouping, it works just the same as the original and obvious print [f(i) for i in a] i think the point of the EXPR in... [EXPR for i in XXX for j in YYY for k in ZZZ...] ...is that EXPR is an expression that can be made up of components of any of the inner loops, i.e., i, j, k, etc., so you should really just think about the loops inside. perhaps you can consider that you're digging a hole and jumping into it. while inside the hole, you dig another one, and jump into *that*, ad nauseum. back at the top, you're only collating the things you want to save and have thrown out from all the holes you've dug yourself into. :-) anyone know if list comps work the same way in haskell? -- wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "Core Python Programming", Prentice Hall, (c)2007,2001 http://corepython.com wesley.j.chun :: wescpy-at-gmail.com python training and technical consulting cyberweb.consulting : silicon valley, ca http://cyberwebconsulting.com _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor