|
|
||||||
|
#1
|
|
|
|
|
#!/usr/bin/python
"""test pydev_0.9.3/../pylint""" __revision__ = "test_mod 0.1 by TV 06/10/22" lst = ['aaa', ' bbb', '\tccc\n'] lst = map(lambda x: x.strip(), lst) result = """ No config file found, using default configuration ************* Module test_mod W: 6: Used builtin function 'map' E: 6: Using variable 'x' before assigment .... """ |
|
|
|
#2
|
|
|
|
|
Tuomas wrote:
> #!/usr/bin/python > """test pydev_0.9.3/../pylint""" > __revision__ = "test_mod 0.1 by TV 06/10/22" > > lst = ['aaa', ' bbb', '\tccc\n'] > lst = map(lambda x: x.strip(), lst) > > result = """ > No config file found, using default configuration > ************* Module test_mod > W: 6: Used builtin function 'map' > E: 6: Using variable 'x' before assigment Some people think that all occurences of map() must be replaced by list comprehensions. The designer of pylint seems to be one of those. Georg |
|
#3
|
|
|
|
|
Tuomas wrote:
> lst = map(lambda x: x.strip(), lst) list comprehensions are more efficient than map/lambda combinations; the above is better written as: lst = [x.strip() for x in lst] in general, map() works best when the callable is an existing function (especially if it's a built-in). not sure if pylist is smart enough to tell the difference, though. </F> |
|
#4
|
|
|
|
|
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] 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) """ |
|
#5
|
|
|
|
|
Tuomas wrote:
> 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? See Fredrik's post. There's no error in the expression with map(), it's just less effective than a LC, but only if used with a lambda. > Formally spoken we ase "using variable 'x' before > assigment" in the comprehension too. That's another issue. I'd suggest a bug in pylint. (You probably have a variable called "x" later in the file. My version of pylint (0.12.1) doesn't show this "error". Georg |
|
#6
|
|
|
|
|
Tuomas wrote:
> #!/usr/bin/python > """test pydev_0.9.3/../pylint""" > __revision__ = "test_mod 0.1 by TV 06/10/22" > > lst = ['aaa', ' bbb', '\tccc\n'] > lst = map(lambda x: x.strip(), lst) > > result = """ > No config file found, using default configuration > ************* Module test_mod > W: 6: Used builtin function 'map' > E: 6: Using variable 'x' before assigment > ... > """ In addition to what the others said, note that pylint is entirely configurable. If you don't want to be bothered with warnings about map() which you are going to ignore, a simple modification to the pylint configuration file will prevent it from doing that check. |
|
|
| Similar Threads | |
| working pylint anyone? Hi, until yesterday I was a happy user of pylint. Then I upgraded to ubuntu hardy heron - and the trouble began. The packaged version of pylint (0.13.2) fails with this... |
|
| patching pylint.el Hi, I think this is a bug of pylint.el. But I failed finding a way to submit the bug neither in its official site nor in google. So I post it here wishing it may be useful... |
|
| PyLint results? Hello: I ran the new pylint and my code and I had a few questions on why those are warnings or what I can do to fix them: 1) W: 0: Too many lines in module (1587) Why is... |
|
| [ANN] PyLint 0.11 / astng 0.16 Hi there! I'm please to announce new releases of pylint (0.11) and its underlying library astng (0.16). Those releases should fix a number of crashes and false positive and... |
|
| [ANN] pylint-0.2 Logilab has released pylint-0.2 What's new? ----------- In addition to a large number of bug fixes, this release adds two new checkers, for missing encoding declaration,... |
|
|
All times are GMT. The time now is 08:16 PM. | Privacy Policy
|