Any six, with_metaclass and DeviceMeta example

Hi all;
I'm porting some code to python 3 using six. One problem remain with de python devices trying to make use of six's "with_metaclass".
I tried the following:
class MyDevice(with_metaclass(DeviceMeta, Device)):
but got this error:
File "…/python2.7/site-packages/six-1.10.0-py2.7.egg/six.py", line 805, in with_metaclass
    class metaclass(meta):
TypeError: Error when calling the metaclass bases
    function() argument 1 must be code, not str

Whats' wrong? I did the same with some of my own classes and it works perfectly.

Thanks.
Edited 7 years ago
Hi Nicolas,

In the pytango unit-tests, we've been successfully using six.add_metaclass:

@six.add_metaclass(DeviceMeta)
class MyDevice(Device):
   […]

Does that work for you?

Also, defining the metaclass won't be necessary any more after PR #90 is merged.

This change will become visible with pytango-9.2.1 release.
Hi Nicolas,

I confirm what Vincent says. He helped me with this as described in this issue:

https://github.com/tango-controls/pytango/issues/88

I used both methods for python3 successfully - and I am a beginner smile!

Andy
Hi guys,

Vincent M
Does that work for you?
It does.

Thanks for your replies.
 
Register or login to create to post a reply.