This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients gvanrossum, ncoghlan
Date 2013-08-20.04:58:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376974748.83.0.329764233469.issue18788@psf.upfronthosting.co.za>
In-reply-to
Content
After watching one of the presenters at PyTexas struggle painfully with the fact "print value" doesn't work in Python 3, I decided I had to at least *try* to see if a general "implicit call" syntax was feasible within the constraints of the CPython parser.

The attached patch shows that it is, indeed, possible to implement such a syntax by modifying the definition of expr_stmt to allow for an implicit trailing argument list (using the normal argument syntax).

The key benefit of such a feature is that the following would once again be legal Python syntax:

    print "Hello world!"

Ambiguous cases (such as "expr * expr" and "expr ** expr") obey the rule that implicit calls are very *low* precedence, so you have to use parens to force the call interpretation. Similarly, a bare expression is not call - you must still append () to force a call without arguments.

In addition to being a pain at the interactive prompt, the change of print from a statement to a function has also been noted as one of the biggest problems with compatibility of third party user scripts for Linux distros changing the default system Python to Python 3. This change would mean most Python 2 print statements either do nothing (no arguments), produce an unexpected trailing newline (trailing comma) or work exactly as they do in Python 2. Only those that use the Python 2 redirection syntax continue to trigger a syntax error in Python 3.

While the *code* changes to achieve this behaviour turned out to be relatively small (most of the diff is in the autogenerated parser code), the documentation and general pedagogical impact could be substantially larger.

If there's even an outside chance this could be accepted, I'm happy to work up a full PEP for it.
History
Date User Action Args
2013-08-20 04:59:09ncoghlansetrecipients: + ncoghlan, gvanrossum
2013-08-20 04:59:08ncoghlansetmessageid: <1376974748.83.0.329764233469.issue18788@psf.upfronthosting.co.za>
2013-08-20 04:59:08ncoghlanlinkissue18788 messages
2013-08-20 04:59:07ncoghlancreate