[Python-ideas] Suggestion: Integrate the script "pindent.py" as standard command for formatting pyhton code
Steven D'Aprano
steve at pearwood.info
Fri May 27 13:21:00 CEST 2011
On Thu, 26 May 2011 09:15:37 pm Serge Hulne wrote:
> It is my feeling that without such a tool Python is inherently very
> vulnerable to glitches occurring at editing time:
I can't think of any language that is invulnerable to the errors you
list. All languages are vulnerable to glitches occurring at edit time.
Picking your second example:
> 2. Tab key inadvertently hit.
If you inadvertently hit the tab key in the middle of a line:
n = le n(mylist) # oops, hit the tab key!
do you expect it to keep working? No. Then why treat the start of the
line any different? There might be some places that, *by chance*, an
extra tab won't break the code:
n = len( mylist)
but you shouldn't rely on that. In general, you should expect ANY and
EVERY mutation of source code could break your code, and avoid tools or
practices that insert arbitrary changes you didn't intend. Don't let
your cat walk on the keyboard while editing source code, don't put your
code through a tool that turns text into fake Swedish, and don't use
tools that mangle whitespace. It is commonsense really.
There are broken tools out there -- especially web forum software --
that arbitrarily mutate whitespace in source code. Those tools are
broken, and should be avoided. If you can't avoid them, you have my
sympathy, but that's your problem, not Python's, and Python doesn't
need to be integrated with a tool for fixing broken source code.
--
Steven D'Aprano
More information about the Python-ideas
mailing list