assignment in a for loop

bruno at modulix onurb at xiludom.gro
Wed May 17 08:02:40 EDT 2006


MackS wrote:
(snip)
>>What's preventing the use of list comprehensions?
>>
>>    new_list = [x+1 for x in old_list]
>  
> Suppose I want to do anything as trivial as modify the values of the
> list members _and_ print their new values. 

Then it's a sure design smell IMHO. Don't mix presentation with logic.

> List comprehensions must not
> contain statements, I think. 

You're right.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list