[Python-projects] possible pylint improvement? "Method could be a function"

Alexandre Fayolle alexandre.fayolle at logilab.fr
Thu Mar 27 18:11:16 CET 2008


On Thu, Mar 27, 2008 at 06:00:34PM +0100, Alexandre Fayolle wrote:
> On Thu, Mar 27, 2008 at 05:55:43PM +0100, Aurélien Campéas wrote:
> > On Thu, Mar 27, 2008 at 11:35:17AM -0500, Connor, Adam J wrote:
> > > Hi, 
> > > For R0201, "Method could be a function", Pylint gives me false positives
> > > on implementations like
> > > 
> > >     def __lt__(self, other):
> > >         return NotImplemented
> > 
> > didn't you  mean
> > 
> >          raise NotImplementedError 
> 
> No, return NotImplemented is correct in the context of __lt__ (though
> generally there is a test on the type of other). When a.__lt__(b)
> returns NotImplemented, the python interpreter uses b.__ge__(a) as the
> return value. 

Well actually, it does not. See [0] for the whole story. 

IronPython seems to [1]. 

[0] http://www.python.org/dev/peps/pep-0207/
[1] http://www.voidspace.org.uk/python/articles/comparison.shtml

-- 
Alexandre Fayolle                              LOGILAB, Paris (France)
Formations Python, Zope, Plone, Debian:  http://www.logilab.fr/formations
Développement logiciel sur mesure:       http://www.logilab.fr/services
Informatique scientifique:               http://www.logilab.fr/science
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 481 bytes
Desc: Digital signature
Url : http://lists.logilab.org/pipermail/python-projects/attachments/20080327/3e5612ce/attachment.pgp 


More information about the Python-Projects mailing list