Linux/Unix > Python Essential Reference, Second Edition > C. Summary of Changes > Python 2.1 | See All Titles

< BACK | Make Note | Bookmark |

155117184014003188065099048180054212144238241179195140058238111161104059122177194220160032

### Python 2.1

- Functions now define nested scopes. Currently, this feature must be enabled by including `from _ _future_ _ import nested_scopes` in your program. In future releases, this feature will be enabled by default.

- Rich comparisons and the associated `_ _le_ _()`, `_ _lt_ _()`, `_ _eq_ _()`, `_ _ne_ _()`, `_ _gt_ _()`, and `_ _ge_ _()` methods.

- `d` `.popitem()` method added to dictionaries.

- `f` `.xreadline()` method added to files to support fast iteration over lines.

- Functions and methods can now have attributes attached to them.

- Support for weak references added. A new module, `weakref`, provides an interface.

  ?; See Also weakref (124).

- Warning framework added. The `warnings` module provides an interface.

  ?; See Also warnings (121).

- Case-sensitive import now supported on non–case-sensitive platforms.

- Interactive display hook (`sys.displayfunc`) added.

- Uncaught exception hook (`sys.exceptfunc`) added.

- `from _ _future_ _` directive added to allow optional use of new features.

- Complex numbers can now only be compared for equality. Comparisons of `<`, `>`, `<=`, or `>=` raise a `TypeError` exception.

- The `continue` statement can now be used inside `try` blocks. This was previously illegal.

- New modules described in Appendix A: `warnings`, `weakref`.

- Modules can now specify a list of symbols to export in the `from module import *` statement by specifying a list `_ _all_ _`.

- Many minor changes to output formatting. The `%x`, `%X`, and `%o` format codes now always produce a sign character for negative long integers. The `repr()` function uses standard character escape codes such as `"\n"` instead of `"\012"`.

| Last updated on 3/28/2002 Python Essential Reference, Second Edition, © 2002 New Riders Publishing

< BACK | Make Note | Bookmark |

© 2002, O'Reilly & Associates, Inc.