On 5/24/21 8:24 AM, Chris Angelico wrote:
> On Tue, May 25, 2021 at 12:18 AM hw <h...@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").

Is it really shadowing, though?  The old one is not only inaccessible,
it's possibly reaped by the garbage collector, no?  Both nums are in the
same scope so the one overwrote the other in the name table.  Or am I
missing something.

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to