PEP-xxx: Unification of for statement and list-comp syntax

bruno at modulix onurb at xiludom.gro
Mon May 22 04:30:52 EDT 2006


Edward Elliott wrote:
> George Sakkis wrote:
> 
> 
>>Em Dom, 2006-05-21 às 17:11 +0200, Heiko Wundram escreveu:
>>
>>>for node in tree if node.haschildren():
>>><do something with node>
>>>
>>>as syntactic sugar for:
>>>
>>>for node in tree:
>>>if not node.haschildren():
>>>continue
>>><do something with node>
> 
> [snip]
> 
>>2) "There should be one and preferably only one way to do it."
> 
> 
> You mean like this:
> 
> s = "foo" + "bar"
> s = 'foo' + 'bar'
> s = 'foo' 'bar'
> s = '%s%s' % ('foo', 'bar')
> 
> This one and only one way stuff is overrated.  I don't care how many ways
> there are as long as:
> 1. at least one way is intuitive
> 2. every way is easily comprehendible (readable, no side effects, etc)

The real mantra is actually :
"There should be one-- and preferably only one --obvious way to do it"

Please note the "should", "preferably", and "obvious".

My 2 cents
-- 
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