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 ...

Get Python Essential Reference, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.