[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gnulib-tool.py: Remove some unused variables.
From: |
Bruno Haible |
Subject: |
Re: gnulib-tool.py: Remove some unused variables. |
Date: |
Sun, 14 Apr 2024 19:54:42 +0200 |
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