Stephen McInerney wrote: > Hi Alan, > > > [ snipage ] >> As to your particular case one non while option would be a generateor: >> >> def half(n): >> while int(n) > 0: >> n = n/2 >> yield n >> >> for x in half(300): print x, >> > > It's ok but it's visually clunky. while-loop wins for clarity. lambda would > also be too quirky. > I know the generator is more runtime-efficient. > It's regrettable we have to choose between the clear and the efficient, in > this situation. >
That statement seems to be founded on the assumption that the C syntax is clear, which has not been established. It is clear to you because it is what you're used to seeing. Slap it down in front of a programmer that has never seen the idiom and see what they make of it. Any time you change languages you have to accustom yourself to it's nuances. C is probably one of the hardest languages I ever learned, I can't remember how many times I read and re-read the K&R chapter on pointer syntax. e. _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor