print v. print()

Thomas Jollans thomas at jollybox.de
Sat Aug 14 11:30:28 EDT 2010


On Saturday 14 August 2010, it occurred to Frederick Williams to exclaim:
> I am learning Python from Hammond & Robinson's _Python Programming on
> Win32_, January 2000 edition.  This
> 
>    print "Sleeping for 10 seconds"
> 
> which appears in some example code, fails to... um... Compile?
> Interpret?  Well, whatever the word is, it fails.  Trial and error
> revealed that
> 
>    print("Sleeping for 10 seconds")
> 
> does the trick.  I am using version 3.1.2, presumably the book's authors
> used some earlier version.

Yes, indeed. Python 3.0 changed a number of things, the most visible is 
removing the print statement in favour of the print() function.
 
> So why the change from print to print()?

There's no reason for print to be a statement -- it can just as well be a 
function, which makes the language more regular, and therefore quite possibly 
easier to learn.

> 
> I should warn you that I know nothing about computers in general or
> Python in particular.



More information about the Python-list mailing list