Python 什么是';范围';派林评论

Python 什么是';范围';派林评论,python,python-3.x,pylint,Python,Python 3.x,Pylint,各种pylint注释/注释的范围是什么?例如: # myfile.py import math import operator as op # pylint: disable=something <----- (1) scope here? # pylint: disable=something <-- (2) scope here? class MyClass: # pylint: disable=something <-- (3) scope here? #

各种pylint注释/注释的范围是什么?例如:

# myfile.py

import math
import operator as op

# pylint: disable=something <----- (1) scope here?

# pylint: disable=something <-- (2) scope here?
class MyClass: # pylint: disable=something <-- (3) scope here?
    # pylint: disable=something <-- (4) scope here?
    def __init__(self):
        print ("HI")      #  pylint: disable=something <--- (5) scope here?

# pylint:disable=something <-- (6) scope here?
def myfunc(num): # pylint: disable=something <-- (7) scope here?
    print ("HI")
#myfile.py
输入数学
作为op导入运算符

#pylint:disable=something如果行上只有注释:范围是当前上下文,从disable注释到上下文末尾,除非有enable,否则它是从disable注释到enable注释。(与您定义的变量范围相同)

如果行上还有代码:范围仅为行

即:

#pylint:disable=某些东西
#不活跃的东西
#pylint:enable=something
#活跃的事物
#pylint:disable=something
#不活跃的东西
def函数_context():
#pylint:disable=其他内容
#不活跃的东西
a=42 35; pylint:enable=something('something'在此行处于活动状态)
#不活跃的东西
#其他不活跃的东西
#还有别的活动吗
看看这是否有帮助-