开发者

Using PyFlakes and the del operator

When making use of del in a Python function, I'm getting false positives from PyFlakes telling me that the variable is undefined.

def foo(bar):
    # what if it's ham? eww
    if bar == 'ham':
        del bar
        return
    # otherwise yummy!
    print bar

The a开发者_如何学Cbove function will return the following error:

C:\temp\test.py:7: undefined name 'bar'

Even though the function will work. Does anyone know of a patch to tweak the ast tree parsing to change how it's being handled? If this something others have run into?


So what is your question? Deleting parameter names does not make any sense at all, so this is no real issue anyways ...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜