1

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 1

1

The list of removed built-ins in 3.0 can be found here.

There are a few functions that were renamed:

  • intern() was moved to sys.intern().
  • raw_input() was renamed to just input(). The old behaviour can be emulated by using eval(input()).
  • reduce() was moved to functools.reduce().
  • reload() was moved to imp.reload() in 3.0, and subsequently moved to importlib.reload in 3.4.
  • xrange() was renamed to range(), replacing the old range() builtin.

And one function resurrected:

  • callable(), which was removed in 3.0 and resurrected in 3.2.
Sign up to request clarification or add additional context in comments.

6 Comments

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.
@ShadowRanger Added!
xrange() to range() is another significant one.
Thanks! This is what I was looking for.
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.
|

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.