Hi Collin,

> There are a few cases of statements like this:
> 
>       var = None
>       try:
>           # do something
>           var = True
>        except:
>           var = False
> or:
> 
>      var = None
>      if other_condition:
>          var = True
>      else:
>          var = False
> 
> Since the 'var' will be set to a bool unconditionally, the None is
> never used.

Yup. It seems that I did not know about [1] when I wrote this code.

Thanks for the patch. Applied with corrected wording in ChangeLog:
When you remove
       var = None
here, you are not removing a variable, but an assignment.

Bruno

[1] 
https://stackoverflow.com/questions/2829528/whats-the-scope-of-a-variable-initialized-in-an-if-statement




Reply via email to