[Python-projects] [Fwd: Re: pylint: What's wrong with the builtin
map()]
Tuomas
tuomas.vesterinen at pp.inet.fi
Sun Oct 22 21:14:22 CEST 2006
Beneath is a citate from comp.lang.python. I got an answer that list
comprehension is more efficent than a map() with lambda. I am happy with
that explanation, but what about message "E: 6: Using variable 'x'
before assigment". What is the motivation of it? Technically speaking we
are "Using variable 'x' before assigment" in the comprehension too, but
there we have no ugly message.
Tuomas Vesterinen
-------- Original Message --------
Subject: Re: pylint: What's wrong with the builtin map()
Date: Sun, 22 Oct 2006 18:31:22 GMT
From: Tuomas <tuomas.vesterinen at pp.inet.fi>
Organization: Sonera corp Internet services
Newsgroups: comp.lang.python
References: <MnO_g.219$P33.22 at read3.inet.fi>
<ehgc24$6vh$1 at news.albasani.net>
Georg Brandl wrote:
> Some people think that all occurences of map() must be replaced
> by list comprehensions. The designer of pylint seems to be
> one of those.
So it seems, but why? Formally spoken we ase "using variable 'x' before
assigment" in the comprehension too.
#!/usr/bin/python
"""test pydev_0.9.3/../pylint"""
__revision__ = "test_mod 0.2 by TV 06/10/22"
lst = ['aaa', ' bbb', '\tccc\n']
# lst = (lambda x: x.strip(), lst) # revision 0.1
lst = [x.strip() for x in lst] # revision 0.2
result = """revision 0.1:
No config file found, using default configuration
************* Module test_mod
W: 6: Used builtin function 'map'
E: 6: Using variable 'x' before assigment
...
revision 0.2:
...
Your code has been rated at 10.00/10 (previous run: -10.00/10)
"""
More information about the Python-Projects
mailing list