isinstance() and multiple inheritance/ctypes
rgaddi at technologyhighland.invalid
Thu Aug 27 01:42:56 CEST 2015
On Thu, 27 Aug 2015 09:12:55 +1000, Chris Angelico wrote:
> You're omitting some context here, but after poking around with your
> module a bit, I'm guessing you created bf somewhat thus?
>>>> bf = bitfield.make_bf("bf", (("asdf",bitfield.c_uint,2),))
> <class 'bitfield.bf'>
> (<class 'bitfield.bf'>, <class '_ctypes.Union'>, <class
> '_ctypes._CData'>, <class 'bitfield.Bitfield'>, <class 'object'>)
> <class '_ctypes.UnionType'>
> (<class '_ctypes.UnionType'>, <class 'type'>, <class 'object'>)
> If that's the case, then it's quite correct: bf is not a Bitfield, it is
> a subclass of bitfield.
Yep, you're quite right. bf is a subclass, not an instance, hence
issubclass is True and isinstance is False. One of those days with too
many lines of code and not enough cups of coffee to compensate.
Thanks for the help, my stupid mistake.
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
More information about the Python-list