Update locals() / resolved
holger krekel
pyth at devel.trillke.net
Tue Apr 30 15:05:53 EDT 2002
On Tue, Apr 30, 2002 at 06:35:51PM +0000, Magnus Lie Hetland wrote:
> 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...
right. i do it all the time for file,str,dict,string,list...
they are simply to short and descriptive to be left bound
to something i don't access directly. and using type('') or
friends is usually a very precise way of expressing that
you want the type object for that particular thing.
regards,
holger
More information about the Python-list
mailing list