Proposal: local variable declarations and type advice

Jeff Shannon jeff at ccvcorp.com
Wed Feb 27 18:19:48 EST 2002


Paul Rubin wrote:

>
> What I mean is if you say
>
>   if x:
>     temp = frob()
>     mumble(temp)
>     foo()
>     bar()
>     del temp
>
> and the foo() or one of the other calls raises an exception that's caught
> by some outer block in the same function, then temp hasn't been deleted,
> and in fact the code could even depend on it not being deleted.  So del
> doesn't give you the same effect as local scope.

Ah, yes, got it.  That does make sense.  I don't see using try/finally as
being too onerous, in cases where you *need* to have certain names cleaned up
(which would seem a moderately rare occurence, to me), but I can see that
being able to declare a local scope would be a bit cleaner.  I'm inclinded to
think that the need for local-scope-inside-function-scope is not frequent
enough to justify a language change to be cleaner than try/finally, but maybe
it's just because I've been working in relatively straightforward application
areas.

Jeff Shannon
Technician/Programmer
Credit International






More information about the Python-list mailing list