2to3print statementhas_key() dictionary methodfilter() global functionmap() global functionapply() global functionintern() global functionexec statementrepr literals (backticks)try...except statementraise statementthrow statementlong data typexrange() global functionraw_input() and input() global functionsfunc_* function attributesxreadlines() I/O methodlambda functions with multiple parameters__class__ special class attributenext() iterator method__nonzero__ special class attributesys.maxintunicode() global functioncallable() global functionzip() global functionStandardError() exceptiontypes module constantsbasestring datatypeitertools modulesys.exc_type, sys.exc_value, sys.exc_tracebackos.getcwdu() functionset() literalsbuffer() global functionFIXME intro
...
print statementFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | print |
print() |
| ② | print 1 |
print(1) |
| ③ | print 1, 2 |
print(1, 2) |
| ④ | print 1, 2, |
print(1, 2, end=' ') |
| ⑤ | print >>sys.stderr, 1, 2, 3 |
print(1, 2, 3, file=sys.stderr) |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | if x <> y: |
if x != y: |
| ② | if x <> y <> z: |
if x != y != z: |
has_key() dictionary methodFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | aDictionary.has_key("PapayaWhip") |
"PapayaWhip" in aDictionary |
| ② | aDictionary.has_key(x) or aDictionary.has_key(y) |
x in aDictionary or y in aDictionary |
| ③ | aDictionary.has_key(x + y) |
(x + y) in aDictionary |
| ④ | x + aDictionary.has_key(y) |
x + (y in aDictionary) |
| ⑤ | aDictionary.has_key(x or y) |
(x or y) in aDictionary |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | aDictionary.keys() |
list(aDictionary.keys()) |
| ② | aDictionary.items() |
list(aDictionary.items()) |
| ③ | aDictionary.iterkeys() |
iter(aDictionary.keys()) |
| ④ | [i for i in aDictionary.iterkeys()] |
[i for i in aDictionary.keys()] |
| ⑤ | min(aDictionary.keys()) |
no change |
filter() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | filter(aFunction, aList) |
list(filter(aFunction, aList)) |
| ② | list(filter(aFunction, aList)) |
no change |
| ③ | filter(None, aList) |
[i for i in aList if i] |
| ④ | for i in filter(None, aList) |
no change |
| ⑤ | [i for i in filter(aFunction, aList)] |
no change |
map() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | map(aFunction, 'PapayaWhip') |
list(map(aFunction, 'PapayaWhip')) |
| ② | map(None, 'PapayaWhip') |
list('PapayaWhip') |
| ③ | map(lambda x: x+1, range(42)) |
[x+1 for x in range(42)] |
| ④ | for i in map(aFunction, aList): |
unchanged |
| ⑤ | [i for i in map(aFunction, aList)] |
unchanged |
apply() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | apply(aFunction, args) |
aFunction(*args) |
| ② | apply(aFunction, args, kwds) |
aFunction(*args, **kwds) |
| ③ | apply(aFunction, args + z) |
aFunction(*args + z) |
| ④ | apply(aModule.aFunction, args) |
aModule.aFunction(*args) |
intern() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | intern(aString) |
sys.intern(aString) |
exec statementFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | exec codeString |
exec(codeString) |
| ② | exec codeString in aGlobalNamespace |
exec(codeString, aGlobalNamespace) |
| ③ | exec codeString in aGlobalNamespace, aLocalNamespace |
exec(codeString, aGlobalNamespace, aLocalNamespace) |
repr literals (backticks)FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | `x` |
repr(x) |
| ② | `1 + 2` |
repr(1 + 2) |
| ③ | `"PapayaWhip" + `2`` |
repr("PapayaWhip" + repr(2)) |
try...except statementFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | |
|
| ② | |
|
| ③ | |
unchanged |
| ④ | |
unchanged |
raise statementFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | raise MyException, "error message" |
raise MyException("error message") |
| ② | raise MyException, "error message", aTraceback |
raise MyException("error message").with_traceback(aTraceback) |
| ③ | raise "error message" |
unsupported |
throw statementFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | aGenerator.throw(MyException) |
unchanged |
| ② | aGenerator.throw(MyException, "error message") |
aGenerator.throw(MyException("error message")) |
| ③ | aGenerator.throw("error message") |
unsupported |
long data typeFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | x = 1000000000000L |
x = 1000000000000 |
| ② | x = 0xFFFFFFFFFFFFL |
x = 0xFFFFFFFFFFFF |
| ③ | long(x) |
int(x) |
| ④ | type(x) is long |
type(x) is int |
| ⑤ | isinstance(x, long) |
isinstance(x, int) |
xrange() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | xrange(10) |
range(10) |
| ② | aList = range(10) |
aList = list(range(10)) |
| ③ | [i for i in xrange(10)] |
[i for i in range(10)] |
| ④ | for i in range(10): |
unchanged |
| ⑤ | sum(range(10)) |
unchanged |
raw_input() and input() global functionsFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | raw_input() |
input() |
| ② | raw_input("prompt") |
input("prompt") |
| ③ | input() |
eval(input()) |
| ④ | input("prompt") |
eval(input("prompt")) |
func_* function attributesFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | aFunction.func_closure |
aFunction.__closure__ |
| ② | aFunction.func_doc |
aFunction.__doc__ |
| ③ | aFunction.func_name |
aFunction.__name__ |
| ④ | aFunction.func_defaults |
aFunction.__defaults__ |
| ⑤ | aFunction.func_code |
aFunction.__code__ |
| ⑥ | aFunction.func_globals |
aFunction.__globals__ |
| ⑦ | aFunction.func_dict |
aFunction.__dict__ |
xreadlines() I/O methodFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | for line in aFile.xreadlines(): |
for line in aFile: |
| ② | for line in aFile.xreadlines(5): |
unchanged |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | |
import io |
| ② | import cPickle |
import pickle |
| ③ | import __builtin__ |
import builtins |
| ④ | import copy_reg |
import copyreg |
| ⑤ | import Queue |
import queue |
| ⑥ | import SocketServer |
import socketserver |
| ⑦ | import ConfigParser |
import configparser |
| ⑧ | import repr |
import reprlib |
| ⑨ | import commands |
import subprocess |
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | import dbm |
import dbm.ndbm |
| ② | import gdbm |
import dbm.gnu |
| ③ | import dbhash |
import dbm.bsd |
| ④ | import dumbdbm |
import dbm.dumb |
| ⑤ | |
import dbm |
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | import xmlrpclib |
import xmlrpc.client |
| ② | |
import xmlrpc.server |
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | import httplib |
import http.client |
| ② | import Cookie |
import http.cookies |
| ③ | import cookielib |
import http.cookiejar |
| ④ | |
import http.server |
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | import urllib |
import urllib.request, urllib.parse, urllib.error |
| ② | import urllib2 |
import urllib.request, urllib.error |
| ③ | import urlparse |
import urllib.parse |
| ④ | import robotparser |
import urllib.robotparser |
| ⑤ | |
|
| ⑥ | |
|
lambda functions with multiple parametersFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
__class__ special class attributeFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
next() iterator methodFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
__nonzero__ special class attributeFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
sys.maxintFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
unicode() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
callable() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
zip() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
StandardError() exceptionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
types module constantsFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
basestring datatypeFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
itertools moduleFIXME intro
this includes fixer_itertools, fixer_itertools_imports
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
sys.exc_type, sys.exc_value, sys.exc_tracebackFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
os.getcwdu() functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
set() literalsFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
buffer() global functionFIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |
FIXME intro
| Notes | Python 2 | Python 3 |
|---|---|---|
| ① | FIXME |
FIXME |