No typical loops, and other crazy ideas

Peter Otten __peter__ at web.de
Thu Jan 6 09:32:35 CET 2005


Bulba! wrote:

> motivation). I've tried to manipulate the data just in Python
> and not in typical loops. One thing that may not be entirely

A list comprehension is just a fancy way to write a loop. Resisting the
temptation to use it can sometimes improve your code.

> [Also, for some reason the advice by another poster, to
> use:
> 
> oldl=list(orig)
> 
> instead of:
> 
> oldl=[x for x in orig]
> 
> ..somehow didn't work. The first instruction has produced only empty
> lists.]
> 
> 
> #---------Code follows-----------

[...]

> #oldl=list(orig)
> #newl=list(orig)

Because you used the same reader twice newl will always be empty. 

Peter





More information about the Python-list mailing list