为什么Pylint不喜欢内置函数? [英] Why doesn't Pylint like built-in functions?

查看:71
本文介绍了为什么Pylint不喜欢内置函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样一行:

filter(lambda x: x == 1, [1, 1, 2])

Pylint显示警告:

Pylint is showing a warning:

W:  3: Used builtin function 'filter'

那是为什么?列表理解是推荐的方法吗?

Why is that? is a list comprehension the recommended method?

我当然可以这样重写:

[x for x in [1, 1, 2] if x == 1]

我没有收到任何警告,但是我想知道是否为此有PEP?

And I get no warnings, but I was wondering if there's a PEP for this?

推荐答案

Pylint经常chat不休.您可以在.pylintrc文件中禁用该警告.

Pylint often chatters on about stuff it shouldn't. You can disable the warning in a .pylintrc file.

此页面 http://pylint-messages.wikidot.com/messages:w0141表示问题在于过滤器和地图已被列表推导取代.

This page http://pylint-messages.wikidot.com/messages:w0141 indicates the problem is that filter and map have been superseded by list comprehensions.

在pylintrc文件中这样的一行将使警告消失:

A line like this in your pylintrc file will quiet the warning:

disable=W0141

这篇关于为什么Pylint不喜欢内置函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆