Pylint doesn't detect an undefined variable in an 'else' clause

Viewed 1005

I have the following python code

a = 2
if a == 1:
    b = 'blah'
    print b
else:
    print b

When I try to run it, I get a runtime error since 'b' is only defined in the 'if' clause, not the 'else'.

Pylint and Pyflakes both failed to detect this issue.

Is there any other way I can detect it without running the code?

1 Answers
Related