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:
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 effecti
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).
#!/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:
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:
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
"""tes