开发者

Are there any guidelines available for beginning Python with Python 2.6 to write applications easily migratable to Python 3 in future? [duplicate]

This question alr开发者_StackOverflow社区eady has answers here: Closed 12 years ago.

Possible Duplicate:

Tips on upgrading to python 3.0?

I am beginning Python and Python 3 is hardly a choice today. But I want the new code I write to have no problems running or being converted to Python 3. Are there any issues known that I should keep in mind for this?


The full correct answer is in the comments, of course - but if you only do one thing to prepare for Python 3, make it learning to use parentheses with 'print'.

Python 2.x:

print 'Hello, World!'

Python 3.x:

print('Hello, World!')

It's the number one most common error in my code when I try to write Python 3.

(And since both methods work with 2.x, you might as well go ahead and get used to using the parens!)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜