[docs] FW: Python 3.4 question - print is now a function...

Zachary Ware zachary.ware+pydocs at gmail.com
Wed May 28 19:30:12 CEST 2014


Hi,

On Wed, May 28, 2014 at 11:36 AM, Dr CL Tondo <drtondo at t3works.com> wrote:
> Hi,
> I found out that print is a function starting with Python 3.0
> It could have been flagged as a deprecated command instead
> of a plain “syntax error.”

First, I'd like to note that this list is not the proper venue for
usage questions such as this one; this list (docs at python.org) is
intended for discussion of the Python documentation.  A better choice
would have been python-list at python.org, which is meant for any and all
discussion pertaining to Python.

That said, I'm glad you figured out your issue yourself!  For a bit of
history, Python 3.0 was used as an opportunity to break backward
compatibility with Python 2.x and clean up many many dark and dusty
corners of the language, and as such was effectively released as a
brand new language: hence the lack of deprecation warnings.  As
further justification for the SyntaxError not being a deprecation
warning, in Python 3, print is just the same as any other function:
you'll get the same SyntaxError from this in any version of Python:

   >>> def foo(arg):
   ...     return arg
   ...
   >>> foo 'test'
     File "<stdin>", line 1
       foo 'test'
                ^
   SyntaxError: invalid syntax

For Python 3 to produce a deprecation notice for print, the
SyntaxError constructor would have to somehow special case the name
'print', which would just be ugly :)

I hope this helps things make a bit more sense, and I hope you enjoy
using Python!

Regards,
--
Zach


More information about the docs mailing list