[Python-projects] * has no '__class__' member
Sylvain Thénault
sylvain.thenault at logilab.fr
Sat Jul 8 11:19:07 CEST 2006
On Saturday 08 July à 04:34, MATSUI Tetsushi wrote:
> Hello,
Hello,
> I found pylint complains about the __class__ attribute for many
> built-in types.
>
> Here is a dull example code runs without an error:
>
> print (1).__class__
> print (1L).__class__
> print "1".__class__
> print object.__class__
> print object().__class__
>
> class Empty (object):
> "an empty class"
>
> print Empty.__class__
> print Empty().__class__
>
>
> The result of the above:
>
> <type 'int'>
> <type 'long'>
> <type 'str'>
> <type 'type'>
> <type 'object'>
> <type 'type'>
> <class '__main__.Empty'>
>
>
> pylint complains 5 times about __class__ out of 7:
>
> E: 1: Instance of 'int' has no '__class__' member
> E: 2: Instance of 'long' has no '__class__' member
> E: 3: Instance of 'str' has no '__class__' member
> E: 4: Class 'object' has no '__class__' member
> E: 10: Class 'Empty' has no '__class__' member
>
>
> I hope this behavior be fixed.
>
>
> Only old style classes have no __class__ members as far as I tried.
> For example:
>
> class OldStyle:
> pass
>
> OldStyle.__class__
>
> fails with an AttributeError.
yep, and the bug is probably that pylint fail to detect
that int,object and others builtin classes are new style classes. I'll
fix this, thanks for the report.
--
Sylvain Thénault LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
Python et calcul scientifique: http://www.logilab.fr/science
More information about the Python-Projects
mailing list