with_metaclassIt was first introduced in the library six(if I remember correctly), which facilitates the transition from Python 2 to Python 3. This is a smart trick to make code compatible with both of them.
Python 2 :
class Foo(object):
__metaclass__ = FooMeta
Python 3, :
class Foo(metaclass=FooMeta):
pass
with_metaclass(meta) : , meta metaclass ', . , Pythons - 2 3 .
Python : http://docs.python.org/3/reference/datamodel.html#metaclasses
, class Test(MyMeta):, Test, MyMeta. ,
class Test:
__metaclass__ = MyMeta
class Test(metaclass=MyMeta):
...
, python. , , Python 2 , with_metaclass, .