Syntax error for simple script

rurpy at yahoo.com rurpy at yahoo.com
Mon Jun 26 12:41:31 EDT 2017


On 06/26/2017 09:42 AM, Steve D'Aprano wrote:
> On Tue, 27 Jun 2017 01:16 am, Ben S. wrote:
> 
>> print mm + "/" + dd + "/" + yyyy + " " + hour + ":" + mi + ":" + ss
>> ^
>> SyntaxError: Missing parentheses in call to 'print'
>>
>> Whats wrong?
> 
> Did you read the error message?
> 
>     Missing parentheses in call to 'print'
> 
> Is the message not clear enough? The call to print requires parentheses (round
> brackets), like all other functions. 
> 
> print(mm + "/" + dd + "/" + yyyy + " " + hour + ":" + mi + ":" + ss)
> 
> 
> If the error message isn't clear enough, what can we do to make it more clear?

How about:

  In Python 2, 'print' was a statement and did not require
  parenthesis around its argument.  In Python 3 'print' has
  been changed to a function and now, like all functions,
  requires parenthesis around its arguments:
    python 2:  print arg1, arg2,...
    python 3:  print (arg1, arg2,...)

Did you seriously not understand how someone, reading a tutorial or 
book written for Python 2, might be confused when a specific simple
syntax he/she was explicitly told works, doesn't work?  Not everyone 
new to and starting to explore Python appreciates (?!) the major 
compatibility breaks that occurred between Py2 and Py3.  One would
expect that in such a situation, the new user would certainly question
his/her code rather than something changed in Python.

Or better than changing the message, how about leaving it alone and 
simply responding helpfully rather than snappily and condescending to 
inevitable confusion that surely must have been anticipated when the
Python developers chose to make this change.

It's no wonder that some people (often women) who don't like contention, 
find this list rather hostile.



More information about the Python-list mailing list