Old Man Yells At Cloud

Steve D'Aprano steve+python at pearwood.info
Tue Sep 19 20:08:18 EDT 2017


On Wed, 20 Sep 2017 03:44 am, Stefan Ram wrote:

> Steve D'Aprano <steve+python at pearwood.info> did *not* write
> [it was edited/abbreviated by me - S. R.]:
> |disadvantages:
> |0 - it makes print a special thing
> |1 - beginners have to unlearn
> |2 - `print(x, y)` is *not* the same as `print x, y`;
> |3 - it has bizarre syntax that nobody would find normal
> |4 - you can't pass keyword arguments
> |5 - it can't be mocked, shadowed, monkey-patched or replaced for testing;
> |6 - and you can't even write help(print) in the interactive interpreter
> 
>   But a simple "autocorrect" features that adds missing
>   parentheses when the case is clear and obvious would not
>   suffer from most of those drawbacks, except maybe from #2.


A simple "autocorrect" in *what*? The interpreter? The editor? Both?

Do you think Microsoft will consider adding it to Notepad? I seem to recall that
you use an editor which doesn't even auto-indent after a colon.

There's a long and inglorious history of good-intentioned people creating Do
What I Mean systems, like adding semi-colons where they are "obvious" or
leaving them out where they aren't "necessary". They invariably become a source
of confusion, superstition and bugs. DWIM systems always sound like a good idea
and always end up causing more problems than they solve.

http://catb.org/~esr/jargon/html/D/DWIM.html

I don't want my editor or interpreter auto-correcting my code. I have no problem
with a linter or editor flagging what it thinks are errors for me to correct,
but that's as far as it goes.

What makes you think the case is clear or obvious?

    print 1  # print(1) or print1 ?


For what its worth: from Python 3.5 (I think) onwards the error you get is
customized:

py> print 1
  File "<stdin>", line 1
    print 1
          ^
SyntaxError: Missing parentheses in call to 'print'


-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list