python-2.x has a list of non-essential built in functions but python-3.x has no such list, and clearly there are built in functions in python-2.x that are no longer in python-3.x. Is there a list somewhere of all the python-2.x built in functions that were removed in python-3.x?
1 Answer
The list of removed built-ins in 3.0 can be found here.
There are a few functions that were renamed:
intern()was moved tosys.intern().raw_input()was renamed to justinput(). The old behaviour can be emulated by usingeval(input()).reduce()was moved tofunctools.reduce().reload()was moved toimp.reload()in 3.0, and subsequently moved toimportlib.reloadin 3.4.xrange()was renamed torange(), replacing the oldrange()builtin.
And one function resurrected:
callable(), which was removed in 3.0 and resurrected in 3.2.
6 Comments
ShadowRanger
Couple omissions from "renamed" list:
reduce -> functools.reduce, and a multistep rename, reload -> imp.reload (3.0+, deprecated in 3.4) -> importlib.reload (3.4+). Few people used the former, but the latter is commonly used in interactive sessions during development, I usually tweak my PYTHONSTARTUP file (executed only for interactive sessions) to automatically do from importlib import reload so I can use it without explicitly importing or qualifying it.tyteen4a03
@ShadowRanger Added!
John Coleman
xrange() to range() is another significant one.user2876414
Thanks! This is what I was looking for.
ShadowRanger
Note: Py3's
range is better than Py2's xrange. For one, from the start, it had no value or size limits; xrange couldn't produce values outside the range of a C ssize_t, and couldn't have a total number of items greater than SSIZE_MAX. Py3.0 range has no such limits (though you can't take the len if it exceeds SSIZE_MAX), and in later 3.x releases they made other improvements, like O(1) membership testing and logical equality testing, support for slicing, etc. |