Python statements not forcing whitespace is messy?

Steve Holden steve at holdenweb.com
Sat Sep 15 17:49:54 EDT 2007


buffi wrote:
> On Sep 15, 10:11 pm, "J. Cliff Dyer" <j... at sdf.lonestar.org> wrote:
>> buffi wrote:
>>> Am I the only one that thinks that python statements should force
>>> whitespace before and after them?
>>> Right now this is not enforced and for an example these statements are
>>> valid
>>> print"hello"
>>> "foo"if"bar"else"foobar"
>>> for(x,y)in[(1,2),(3,4)]:print(x,y)
>>> [(y)for(x,y)in[("foo",2),("bar",4)]if"foo"in(x)]
>>> ...and so on.
>> On the other hand, this is just as bad:
>>
>> [ ( y ) for ( x , y ) in [ ( "foo" , 2 ) , ( "bar" , 4 ) ] if "foo" in (
>> x ) ]
>>
>> And I'd hate to have to remember all of the rules for what can go
>> together and what can't, especially when it comes time to debug.  No.
>> I don't think it should be forced, but maybe put it in PEP8 or PEP3008.
>>
>> Also, the only thing I find thoroughly disagreeable in all of that
>> mess, is the run-ins involving " characters.  The rest are at least
>> clear at a glance what belongs where.
>>
>> Also, would you require the following?
>>
>> my_function (swallow='European')
>>
>> Because that is just an awful use of whitespace.
>>
>> Cheers,
>> Cliff
> 
> I believe that having whitespace around the builtin statements, and
> having whitespace around everything is pretty different.
> 
> There would be no downside whatsoever to enforcing this, except for
> backwards incompatibility (which is a rather huge downside but well...
> py3k is gonna break everything anyways). There obviously shouldnt be
> any limit to the maximum amount of whitespace used around statements
> (due to formatting and so on), but allowing stuff like print"hello" is
> just horrible.
> 
If you don't like it then don't write it. I've been reading this group 
on and off for about ten years and I believe your email is the first to 
point out that this is possible. Clearly it isn't something that happens 
a lot, and I don't know why you have a bug up your ass about it, as the 
Americans say.

The Python philosophy is to be permissive, and to expect individual 
users to write readable Python. Since they obviously do (one message in 
ten years providing a counter-example) I think you are wasting your time 
and energy on this.

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden

Sorry, the dog ate my .sigline




More information about the Python-list mailing list