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

Re: Python coding help: Has anybody seen this syntax



On Feb 13, 2014, at 05:37 PM, Andreas Tille wrote:

>  File "/usr/share/spades/pyyaml3/__init__.py", line 284
>    class YAMLObject(metaclass=YAMLObjectMetaclass):

This is Python 3 syntax for specifying a metaclass.  Maybe this is somehow
getting executed by Python 2?

There are ways to make metaclass definition multilingual:

http://pythonhosted.org/six/index.html?highlight=metaclass#six.with_metaclass

or if you don't want to pull in the extra dependency:

https://wiki.python.org/moin/PortingToPy3k/BilingualQuickRef#metaclasses

Cheers,
-Barry


Reply to: