Python statements not forcing whitespace is messy?

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Sep 16 02:48:39 CEST 2007


On Sun, 16 Sep 2007 09:14:57 +0900, Ryan Ginstrom wrote:

>> On Behalf Of J. Cliff Dyer
>> On the other hand, this is just as bad:
>> 
>> [ ( y ) for ( x , y ) in [ ( "foo" , 2 ) , ( "bar" , 4 ) ] if "foo" in
>> ( x ) ]
> 
> I think that's allowed in order to recruit C/C++ programmers.

Heh :)

In all seriousness, sometimes, in an extremely crowded and busy 
expression, adding a little extra whitespace to emphasize the boundaries 
between sub-expressions is a good thing. And let's not forget that we can 
do this:

>>> complex_expression = (
... 2*x +             # double the whatzit
... 1.78**(c*3-1) +   # see chapter 2 of Martelli, 2008
... sin(radians(80))  # angle between the foo and the bar
... )



-- 
Steven.



More information about the Python-list mailing list