Re: Python coding help: Has anybody seen this syntax
This is a python3 syntax change; in python3 you can pass an optional
metaclass for a class, which you can't do in python2, IIRC.
Code works for me in Python3, not python 2.7.6
regards
Al
On 13/02/2014 16:37, Andreas Tille wrote:
> class YAMLObjectMetaclass(type):
> """
> The metaclass for YAMLObject.
> """
> def __init__(cls, name, bases, kwds):
> super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds)
> if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None:
> cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml)
> cls.yaml_dumper.add_representer(cls, cls.to_yaml)
>
> class YAMLObject(metaclass=YAMLObjectMetaclass):
> """
> An object that can dump itself to a YAML stream
> and load itself from a YAML stream.
> """
--
Alastair McKinstry , <alastair@sceal.ie> , <mckinstry@debian.org> http://blog.sceal.ie
Anyone who believes exponential growth can go on forever in a finite world
is either a madman or an economist - Kenneth Boulter, Economist.
Reply to: