Changes between Version 1 and Version 2 of python2and3CompatiblityEN


Ignore:
Timestamp:
May 26, 2013, 4:49:31 PM (11 years ago)
Author:
Martin Kolman
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • python2and3CompatiblityEN

    v1 v2  
    99
    1010== Library renaming ==
     11
     12== The print() function ==
     13In Python 3, ''print'' is no longer a statement but a function. Using:
     14{{{
     15print "Hello world"
     16}}}
     17Will result in syntax error exception.
     18
     19The correct way in Python 3 is:
     20{{{
     21print("Hello world")
     22}}}
     23
     24Fortunately, the print function can be used as far back as Python 2.5, so no version specific code is needed for this. All prints just need to be converted to using the print function. This can be easily done automatically using regular expressions or semi-automatically with the ubiquitous search and replace functionality available in most editors.