Linux Today: Linux News On Internet Time.

Python 3 Metaclasses and other strange creatures

Feb 06, 2009, 06:05 (0 Talkback[s])
(Other stories by Cesar Otero)

[ Thanks to An Anonymous Reader for this link. ]

"The previous article on Python version 3—also known as Python 3000 or Py3K—discusses some of the basic changes in Python that will break backwards compatibility, such as the new print() function, the bytes data type, and changes to the string type. This article, Part 2, explores some of the more advanced topics, such as abstract base classes (ABCs), metaclasses, function annotations and decorators, integer literal support, the number type hierarchy, and changes to raising and catching exceptions, most of which also break backwards compatibility with the version 2x line.

"Class decorators

"In previous versions of Python, transformations to a method had to be done after the definition of the method. In longer methods, this requirement kept an important component of the definition far removed from the definition of the external interface provided in Python Enhancement Proposal (PEP) 318 (see Resources for a link). This snippet shows an example of this transformation requirement:"

Complete Story

Related Stories: