[Python-projects] [pylint] class members issue
Sylvain Thénault
sylvain.thenault at logilab.fr
Tue Jul 22 15:58:58 CEST 2008
On Mon, Jul 21, 2008 at 05:42:46PM +0100, Nadia Alramli wrote:
> Hi,
Hi,
> I noticed that pylint is not accepting the use of class members as
> arguments to decorators inside the class, example:
>
> def decorator(value):
> def wrapper(function):
> return function
> return wrapper
>
> class foo:
> member = 10
>
> @decorator(member) #This will cause pylint to complain
> def test(self):
> pass
>
> pylint will complain about "Undefined variable 'member'"
>
> while:
> @decorator(foo.member)
> def test(self):
> pass
>
> Will work according to pylint.
>
> However the first case works in python while the second one doesn't.
> Any ideas to workaround this?
this is a bug in astng. I've added a ticket so this should be fixed in
the next astng release:
http://www.logilab.org/ticket/5626
Meanwhile i don't see anyother way than using a global variable outside
the class scope, for instance:
MEMBER = 10
class foo:
member = MEMBER
@decorator(MEMBER)
def test(self):
pass
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