[Baypiggies] padding variable assignments, why is it bad?

Wai Yip Tung tungwaiyip at yahoo.com
Sat Aug 11 01:50:44 CEST 2012

Here a few more examples in Python's standard library to show how 
properly aligned can enhance readability.


This is a pretty common format to align comments on the right hand side. 
You will find lots of examples. It should be easy to conclude the 
comments are more readable if aligned. In fact I'd say the code will be 
unreadable if the comment are not aligned. Yet this format require the 
same effort to keep neat and tidy and can introduce diff in source code 
history some of you object to.


It is very helpful to keep columns aligned when you define a large block 
of data.


This is a direct violation of PEP-8. But this is so much nicer to scan 
the code to do a reverse lookup.


Since PEP-8 does not cover dictionary literals, you tend to find lot 
more examples of people aligning dictionary key names than assignment 
statement. But the two are functionally very similar. Javascript can 
even use one as an alternative style of the other. Obviously people find 
value in this format to apply the extra effort to align them.

I guess I have make justification for this style and I encourage your 
judgement rather than feeling compel by a style guide. And get a good 
editor. It is not only helpful in writing code. Sometimes you find CSV 
file and things become immediately clearer if only you can align the 

Wai Yip

More information about the Baypiggies mailing list