On 01 novembre 23:16, Wolfgang Rohdewald wrote:
> Hi,
Hi,
> what is the correct way to define properties - which
> variant does not give me pylint warnings?
>
> all variants I tried gave me warnings.
which warnings?
> pylint --version
> pylint 0.21.1,
> astng 0.20.1, common 0.50.3
> Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
> [GCC 4.4.5]
>
> I tried
>
> @apply
> def nameid():
> """the name id of this player"""
> def fget(self):
> return Players.allIds[self.name]
> return property(**locals())
>
>
> and
>
> def nameid():
> """the name id of this player"""
> def fget(self):
> return Players.allIds[self.name]
> return property(**locals())
> nameid = nameid()
>
> and the 2.6 property getter/setters like @nameid.getter
hum, pylint doesn't handle any of those forms. It currently grasp:
@property
def nameid(self):
...
and
def nameid(self):
...
nameid = property(nameid)
which are more 'usual' form of properties usage, imo.
--
Sylvain Thénault LOGILAB, Paris (France)
Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
Développement logiciel sur mesure: http://www.logilab.fr/services
CubicWeb, the semantic web framework: http://www.cubicweb.org
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects