Python coding help: Has anybody seen this syntax
Hi,
I'm trying to package spades[1] and found the following code inside an
__init__.py file:
...
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.
"""
__slots__ = () # no direct instantiation, so allow immutable subclasses
yaml_loader = Loader
yaml_dumper = Dumper
...
which ends up in
File "/usr/share/spades/pyyaml3/__init__.py", line 284
class YAMLObject(metaclass=YAMLObjectMetaclass):
^
SyntaxError: invalid syntax
I'm not a very skilled Python coder but IMHO the critical line should be
replaced by
class YAMLObject(YAMLObjectMetaclass):
Is this correct? Do you have any clue whether this is some old syntax
or what sensible hint I might give to upstream?
Thanks for your patience
Andreas.
[1] svn://anonscm.debian.org/debian-med/trunk/packages/spades/trunk/
--
http://fam-tille.de
Reply to: