Update locals() / resolved

Steve Holden sholden at holdenweb.com
Tue Apr 30 14:56:37 EDT 2002


"Magnus Lie Hetland" <mlh at vier.idi.ntnu.no> wrote in message
news:slrnactp07.pv.mlh at vier.idi.ntnu.no...
> In article <fjbz8.7570$M63.5673 at atlpnn01.usenetserver.com>, Steve Holden
wrote:
> [snip]
> >> > Why use type({}) when you can use dict?
> >>
> >[ ... good reasons ...]
> >>
> >> 3. And 'dict' is something i often use in local definitions
> >>    when working with dictionaries.
> >>
> >Yeah, well we all have to cut that out and start using "adict" or
"thisdict"
> >pretty sharpish. This one bites now.
>
> How so? It only "bites" if you actually need access to the dict type
> in the same scope where you bind your variable... I've got plenty of
> code with stuff like
>
>   file = open('foo.bar')
>
> and it doesn't bother me one bit (except in the cases where 'file'
> should have been something more descriptive, I guess ;)
>
> Thes names aren't reserved in any way...
>

I understand that. They just scream out to be overridden in the
module-global namespace, making the builtin version invisible for the
duration of that (dynamic) scope. The problem is when you've overridden
them, and then want to use the built in. I understand exsisting code won't
break: I'm just suggesting that modifications to such code might have
unforeseen consequences.

not-that-you-or-i-would-ever-do-that-ly y'rs  - steve
--

Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/








More information about the Python-list mailing list