
Oct. 25, 2021
6:26 a.m.
On Mon, Oct 25, 2021 at 03:47:29AM +1100, Chris Angelico wrote:
There are two possibilities: either it's a SyntaxError, or it's a run-time UnboundLocalError if you omit both of them (in which case it would be perfectly legal and sensible if you specify one of them).
I'm currently inclined towards SyntaxError, since permitting it would open up some hard-to-track-down bugs, but am open to suggestions about how it would be of value to permit this.
You said it yourself: "perfectly legal and sensible". Why would this be a "hard-to-track-down" bug? You get an UnboundLocalError telling you exactly what the problem is. UnboundLocalError: local variable 'b' referenced before assignment -- Steve