[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Python coding help: Has anybody seen this syntax



* Andreas Tille <andreas@an3as.eu> [140213 17:39]:
>   File "/usr/share/spades/pyyaml3/__init__.py", line 284
>     class YAMLObject(metaclass=YAMLObjectMetaclass):

Hi Andreas,

A class's metaclass is not the same as a base class. It's way to
control how objects are created. The best explanation of metaclasses,
if you're interested, is probably:

https://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python

Usually you define a metaclass using a __metaclass__ attribute, but in
python3, you can also pass a metaclass kwarg. The relevant PEP is:

http://www.python.org/dev/peps/pep-3115/

It seems to me that the cause of your problem is that you're using a
python3 class with a python2 interpreter.

-- 
Etienne Millon


Reply to: