[Python-projects] pylint/astng feature request: namedtuple support

Sylvain Thénault sylvain.thenault at logilab.fr
Thu Mar 26 08:47:14 CET 2009


Le Thursday 26 March 2009 01:33:19 Maarten ter Huurne, vous avez écrit :
> On Thursday 26 March 2009, Vincent Legoll wrote:
> > pylint was failing to detect such cases on meld code (meld.sf.net)
> >
> > from misc.py:
> >
> > class struct(object):
> >     """Similar to a dictionary except that members may be accessed as
> > s.member.
> >
> >     Usage:
> >     s = struct(a=10, b=20, d={"cat":"dog"} )
> >     print s.a + s.b
> >     """
> >     def __init__(self, **args):
> >         self.__dict__.update(args)
> >     def __repr__(self):
> >         r = ["<"]
> >         for i in self.__dict__.keys():
> >             r.append("%s=%s" % (i, getattr(self,i)))
> >         r.append(">\n")
> >         return " ".join(r)
> >     def __cmp__(self, other):
> >         return cmp(self.__dict__, other.__dict__)
> >
> > uses of instances of this class are flagged as errors
>
> This is indeed a similar situation. However, I think it might be very
> difficult for astng to actually understand the code above.

absolutly... I'm not sure it will ever be the case.

> In the case of namedtuple(), it is part of the standard library, so support
> for this particular function could be hardcoded, making it much easier to
> implement.

yepp. http://www.logilab.org/ticket/8766

cheers,
-- 
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