Tabs for indentation & Spaces for alignment in Python 3?

Michael Torrie torriem at gmail.com
Fri Dec 5 22:04:48 EST 2014


On 12/05/2014 07:31 PM, Ned Batchelder wrote:
> This is a perfect example!  The code (with tabs as >--- and leading 
> spaces as .) is:
> 
>   >-------if (!list_empty(pending))
>   >------->-------ret = list_first_entry(pending, struct async_entry,
>   >------->------->------->-------.......domain_list)->cookie;
> 
> Now, display it in your editor with tabs set to four spaces:
> 
>   >---if (!list_empty(pending))
>   >--->---ret = list_first_entry(pending, struct async_entry,
>   >--->--->--->---.......domain_list)->cookie;

However, a conscientious programmer knows that tabs could be arbitrarily
sized, so he would never do that.  Instead he would do:

   >-------if (!list_empty(pending))
   >------->-------ret = list_first_entry(pending, struct async_entry,
   >------->-------.......................domain_list)->cookie;

Which under the heretical tab size of 4:
   >---if (!list_empty(pending))
   >--->---ret = list_first_entry(pending, struct async_entry,
   >--->---.......................domain_list)->cookie;

In fact a decent editor that is auto-indenting code would, at least in C
or C++ mode, do that automatically.

Maybe I misread, but I would think this is what the OP had in mind.
Of course maybe kernel programmers think differently.  Ahh well.







More information about the Python-list mailing list