8

So my work which had used older Python 2 is doing some code updating, anyways I am just learning python and am actually pretty new here, but what are the major syntax changes that went from 2-->3

Or is there really even that much syntax changes at all (like I know print got changed, but what else MAJOR)

Thanks

2
  • 2
    use 2to3 : docs.python.org/library/2to3.html Commented Feb 17, 2011 at 16:27
  • 1
    For casual use, print is probably the thing you will notice the most. If you do any sort of unicode handling, that's very different. Other than that, it should mostly be stuff you can get used to quite quickly. Commented Feb 17, 2011 at 17:29

4 Answers 4

11

What’s New In Python 3.0:
http://docs.python.org/release/3.0.1/whatsnew/3.0.html

PEP: 3000 - Python 3000:
http://www.python.org/dev/peps/pep-3000/

PEP: 3099 - Things that will Not Change in Python 3000:
http://www.python.org/dev/peps/pep-3099/

Sign up to request clarification or add additional context in comments.

1 Comment

The first one is important. There have been several changes in semantics - most should cause the code to fail fast (e.g. using the result of zip or range as a list), but there might be some subtle ones.
5

Did you read this: Overview of Syntax Changes ?

1 Comment

Ya I read the Overview, but it doesn't really state specifics
4

The things you really notice in the syntax are the print statement, and the change in the exception syntax. 2to3 will handle all that.

That won't cause you any headaches though. Those generally come from the split of strings into binary bytes and Unicode strings. 2to3 doesn't handle that.

So the changes in syntax aren't really what you need to worry about. :)

Then there are some minor changes in the syntax, tons of small changes in various functionality and a huge reorganization of the standard library, most of which 2to3 handles.

There isn't any canonical summary of all changes afaik, although I've tried to make one in my new book. There may be some misses, but there you go.

Comments

0

You can't do much better than to read the documentation: http://docs.python.org/release/3.1.2/whatsnew/ covers all the changes pretty succienctly. Read the "What’s New In Python 3.0" section first for the main changes.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.