On Thursday 04 February 2010 15:13:14 Diez B. Roggisch wrote: > On Thursday 04 February 2010 14:15:33 Sam Tygier wrote: > > hello > > > > i wonder if pylint could be made to spot the following error > > > > if ans.lower in ["yes", "y"]: > > > > where the function is compared, rather than calling the function and > > comparing the result. > > > > maybe it could check for any comparison between a function and a > > literal. > > It can't possibly know that lower is a function instead of a simple string. > > > class Foo(object): > > lower = "yes" > > ans = Foo() > > if ans.lower in ["yes", "y"]: > print "yieha" >
In that case, no, but in the following code, pylint can know that ans.lower is a method. class Foo: def lower(self): pass ans = Foo() if ans.lower == "yes": pass Additionnaly, I think that if pylint's type inference indicates that ans is a string object, it could know that ans.lower is a method. -- Alexandre Fayolle LOGILAB, Paris (France) Formations Python, CubicWeb, Debian : http://www.logilab.fr/formations Développement logiciel sur mesure : http://www.logilab.fr/services Informatique scientifique: http://www.logilab.fr/science _______________________________________________ Python-Projects mailing list Python-Projects@lists.logilab.org http://lists.logilab.org/mailman/listinfo/python-projects