On Wed, 20 Apr 2011 11:56:35 +1000, James Mills wrote:

> Hi all,
> 
> Is there a compatible way to use meteclasses in both Python 2.x (2.6 to
> 2.7) and Python 3.x (3.0 to 3.2).


Untested:

if sys.version >= "3":
    kw = {'metaclass': MyMetaClass}
else:
    kw = {}

class Foo(object, **kw):
    if sys.version < "3":
        __metaclass__ = MyMetaClass


Inelegant as it gets, but it should work.



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to