shadows name from outer scope
Terry Reedy
tjreedy at udel.edu
Tue Oct 11 19:13:52 EDT 2016
On 10/11/2016 11:50 AM, Daiyue Weng wrote:
> Hi, I have the following code structure,
>
> def one_func(param1, param2, param3):
>
> process_outcome = {'dict': None}
>
>
> outcome = another_func(param1, process_outcome, db_host=param2,
> funcs_to_run=param3)
>
> PyCharm warns me
>
> Shadows name from outer scope
>
> on every variable here, param1,2,3, process_outcome.
Have you checked that this is true? Code checkers sometimes have bugs.
In any case, we cannot comment on this without code.
> I am wondering how to resolve the issues,
Ignore the warning or turn it off.
> and is it vital to have variables not shadowed?
No, sometimes it is the right thing to do. Some warnings dependably
indicate something wrong. Some do not and are just a hint that maybe
you should think about what you did. Was it accidental (a typo) or
intentional?
--
Terry Jan Reedy
More information about the Python-list
mailing list