meteclasses 2.x/3.x compatibility

James Mills prologic at shortcircuit.net.au
Wed Apr 20 18:36:31 EDT 2011


On Wed, Apr 20, 2011 at 10:18 PM, andrew cooke <andrew at 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 http://code.google.com/p/lepl/source/browse/src/lepl/matchers/matcher.py#40 I have
>
>  _Matcher = ABCMeta('_Matcher', (object, ), {})
>
> and then
>
>  class Matcher(_Matcher):
>      ...

Thank Andrew. I like this approach Elegance wins for me :)

cheers
James

-- 
-- James Mills
--
-- "Problems are solved by method"



More information about the Python-list mailing list