Proposal: local variable declarations and type advice

Terry Reedy tjreedy at home.com
Tue Feb 26 10:06:29 EST 2002


"Paul Rubin" <phr-n2002a at nightsong.com> wrote in message
news:7x3czobs0x.fsf at ruckus.brouhaha.com...
> Local variable declarations are for code cleanliness.  Currently,
using
> some name for a temp variable leaves detritus around after you're
done
> with it.  To figure out what the program is doing, you have to check
> whether further references to 'temp' really wanted the value left
from
> someplace far away, or were holding just a different temporary
value.
> When the usefulness of a variable ends, its scope should also end.

An explicit 'del temp' ends the scope of the variable.  Its not much
more to type that any sort of brackets and allows for overlapping
scope of temporaries instead of artificially forcing nesting.  If you
want to extend the scope of 'temp', it is probably easier to get rid
of the explicit deletion than a pair of brackets.

Terry J. Reedy







More information about the Python-list mailing list