Re: meteclasses 2.x/3.x compatibility

2011-04-20 Thread Steven D'Aprano
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

Re: meteclasses 2.x/3.x compatibility

2011-04-20 Thread andrew cooke
What I do in Lepl is use two stages. The first calls the type/metaclass directly and the second subclasses that. This avoids using the sugar that changes between 2 and 3. So, for example, in http://code.google.com/p/lepl/source/browse/src/lepl/matchers/matcher.py#40 I have _Matcher =

Re: meteclasses 2.x/3.x compatibility

2011-04-20 Thread James Mills
On Wed, Apr 20, 2011 at 10:18 PM, andrew cooke and...@acooke.org wrote: What I do in Lepl is use two stages.  The first calls the type/metaclass directly and the second subclasses that.  This avoids using the sugar that changes between 2 and 3. So, for example, in