Are there any recommendations for running Python with Python 2.6 for writing applications that are easily portable to Python 3 in the future?

Possible duplicate:
Tips to upgrade to python 3.0?

I'm starting Python, and Python 3 is hardly a choice today. But I want the new code that I am writing to not have problems running or converting in Python 3. Are there any problems I have to remember for this?

+4
source share
1 answer

The completely correct answer in the comments, of course, but if you only do one thing to prepare for Python 3, make him learn to use parentheses with "print".

Python 2.x:

print 'Hello, World!' 

Python 3.x:

 print('Hello, World!') 

This is the most common mistake in my code when I try to write Python 3.

(And since both methods work with 2.x, you could also go and get used to using parens!)

+1
source

Source: https://habr.com/ru/post/1310725/


All Articles