[Andreas Tille, 2014-02-13]
> 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

you invoked it using python2.X

> I'm not a very skilled Python coder but IMHO the critical line should be
> replaced by
> 
> 
> class YAMLObject(YAMLObjectMetaclass):                                        
>                                                                               
>                                             

no, metaclass keyword argument was introduced in Python 3.0
-- 
Piotr Ożarowski                         Debian GNU/Linux Developer
www.ozarowski.pl          www.griffith.cc           www.debian.org
GPG Fingerprint: 1D2F A898 58DA AF62 1786 2DF7 AEF6 F1A2 A745 7645


-- 
To UNSUBSCRIBE, email to debian-python-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20140213164952.gf3...@sts0.p1otr.com

Reply via email to