learning python ...

Chris Angelico rosuav at gmail.com
Mon May 24 10:24:25 EDT 2021


On Tue, May 25, 2021 at 12:18 AM hw <hw at adminart.net> wrote:
> There are more alternatives:  Python might create a new variable with
> the same name and forget about the old one.  Or it doesn't forget about
> the old one and the old one becomes inaccessible (unless you have a
> reference to it, if there is such a thing in python).  How do you call that?

It's the latter option: create a new variable, and the old one becomes
inaccessible. That's called "shadowing". It's how scoping works in
most languages (called "lexical scope").

ChrisA


More information about the Python-list mailing list