Introduction
Python 3 was released on December 2008[1][2]. It is not expected that everybody will migrate right away because most third party dependencies won't be ready on the release date. If you have code to migrate to Python 3 and it depends on external libraries, wait until at least version 3.1 to start the migration. Python 3 is a viable option when you are starting a project from scratch and you can rely on built-in function and modules. Although Python 2.x still has a long life ahead, it won't hurt to know what we can expect from the last big release of our favorite programming language.
Datatypes
- All strings are now Unicode.
- Remove distinction between int and long types (L suffix is gone in longs).
- True division is standard (that is, 5/2 now gives 2.5 and not 2 as before)
- dict.has_key(x) is invalid, use "x in dict"
- dict.items(), dict.keys() and dict.values() now returns an iterator instead of a list (use list() to get a list).
- A set can be declared with {1,2,3} instead of set([1,2,3])
Functions
- There are function anotations: def fn(x: int) -> str: (see [3] for more information)
- apply(f,args,kw) is now f(*args, **kw)
- print is now a function[4]: print(1,2,3, sep="",end="\n",file=sys.stdout), allowing it to be used inline rather than having a special syntax
Exceptions
raise Exception, "a message" is now: exception("a message")
Removed
- xrange() is replaced with a new range() function, the new range() will return an iterator instead of a list.
- raw_input() is replaced with a new input() function that does what the old raw_input() did.To use the old input(), do eval(input()) (from a security point of view this is not a good idea).
Compatibility with previous versions
Python 3.0 breaks backwards compatibility with Python 2.x. There is no requirement that Python 2.6 code will run unmodified on Python 3.0.[5] Here is the proposed path to migrate your 2.x programs to 3.0 by using Python 2.6:
- Port your project to Python 2.6.
- Turn on the Py3k warnings mode (with "-3" at command line).
- Test and edit until no warnings remain.
- Use the 2to3 tool to convert this source code to 3.0 syntax. Do not manually edit the output!
- Test the converted source code under 3.0.
- If problems are found, make corrections to the 2.6 version of the source code and go back to step 3.
- When it's time to release, release separate 2.6 and 3.0 tarballs (or whatever archive form you use for releases).
Python 3 talk by Guido Van Rossum







Lan Rogers
Invite as author
Good
EditSaveCancelDeleteDeleteBlock this userReport abusive commentHide report window
EditSaveCancelDeleteDeleteBlock this userReport abusive commentHide report window
Thomas Barron
Invite as author
hm...
EditSaveCancelDeleteDeleteBlock this userReport abusive commentHide report window
EditSaveCancelDeleteDeleteBlock this userReport abusive commentHide report window
EditSaveCancelDeleteDeleteBlock this userReport abusive commentHide report window
Anonymous
Invite as author
Self.Pythong
Bella
Invite as author
WOW
Brice
Invite as author
Outdated
Best,
EditSaveCancelDeleteDeleteBlock this userReport abusive commentHide report window