开发者

Using PyFlakes and the del operator

开发者 https://www.devze.com 2023-01-15 01:39 出处:网络
When making use of del in a Python function, I\'m getting false positives from PyFlakes telling me that the variable is undefined.

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

精彩评论

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

关注公众号