[Python-Dev] [RELEASED] Python 2.7 alpha 2

Jack Diederich jackdied at gmail.com
Tue Jan 12 04:53:24 CET 2010


On Mon, Jan 11, 2010 at 7:11 PM, Barry Warsaw <barry at python.org> wrote:
> As an example, the one library I've already ported used a metaclass.  I don't
> see any way to specify that the metaclass should be used in a portable way.
> In Python 2.6 it's:
>
> class Foo:
>    __metaclass__ = Meta
>
> and in Python 3 it's:
>
> class Foo(metaclass=Meta):
>
> 2to3 made that pain go away.

[sidebar]
1) the metaclass fixer was a PITA to implement.
2) 95% of __metaclass__ definitions searchable via google code were of
the "__metaclass__ = type" variety.  The 2to3 patch exists only
because of the few other uses.
3) 100% of the module level assignments in public projects were the
"__metaclass__ = type" variety which is why there isn't a fixer for
that.  Also, a fixer would have been really, really ugly (munge every
class definition in this module because there is a top level
assignment).

-Jack



More information about the Python-Dev mailing list