PEP8 and 4 spaces

Travis Griggs travisgriggs at gmail.com
Sat Jul 5 03:51:32 EDT 2014


> On Jul 4, 2014, at 11:29, Lie Ryan <lie.1296 at gmail.com> wrote:
> 
>> On 04/07/14 07:55, Gregory Ewing wrote:
>> Steven D'Aprano wrote:
>> 
>>>> That's exactly the problem with tabs - whatever you think your code
>>>> looks like with tabs, other people will see quite different picture.
>>> 
>>> Why do you consider this a problem?
>> 
>> It's a problem if you try to use tabs for lining things
>> up in a tabular fashion in your source code.
>> 
>> The solution is not to use tabs for that -- only use
>> tabs for indentation, and use spaces for everything
>> else. Or, as PEP 8 suggests, don't try to line things
>> up in the first place.
> 
> PEP8 suggests using this style of method invocation:
> 
>    obj.method(foo,
>               bar,
>               baz)
> 
> which is an effect impossible to do correctly with tabs alone. If you want to follow this style strictly, you end up having to either mix tabs and spaces, or just use spaces, or as I prefer it, avoid the issue altogether:
> 
>    obj.method(
>        foo,
>        bar,
>        baz,
>    )

Ok, here's irony. I'm looking at that thinking "what the heck is he talking about?!?". And then my brain catches up. My mail reader is of course "modern" and does not use a mono space font. So the value of the along ed indent is lost anyway. But wasn't that what spaces were supposed to give us over tabs, some separation from the trading betwixt different editors? Chuckle.

Travis Griggs




More information about the Python-list mailing list