python AttributeError: class XXX has no attribute '__class__' -
who can me exception?
file "/root/anaconda2/lib/python2.7/site-packages/numba/dispatcher.py", line 305, in _compile_for_args argtypes.append(self.typeof_pyval(a)) file "/root/anaconda2/lib/python2.7/site-packages/numba/dispatcher.py", line 429, in typeof_pyval file "/root/anaconda2/lib/python2.7/site-packages/numba/typing/typeof.py", line 28, in typeof ty = typeof_impl(val, c) file "/root/anaconda2/lib/python2.7/site-packages/singledispatch.py", line 210, in wrapper return dispatch(args[0].__class__)(*args, **kw) attributeerror: class featureencoding has no attribute '__class__'
not every instance has __class__ attribute. general recommendation: in cases it's better use type instead of __class__ nevertheless.
for example old-style classes don't have class:
>>> class a: ... pass ... >>> a.__class__ attributeerror: class has no attribute '__class__' >>> int.__class__ # comparison class of int class <type 'type'> but type works:
>>> type(a) <type 'classobj'> note: instances of old-style classes have __class__ attribute
>>> = a() >>> a.__class__ <class __main__.a @ 0x0000000002e61168>
Comments
Post a Comment