Python dictionaries are awesome
Dave Angel
d at davea.name
Tue Nov 27 00:27:53 EST 2012
On 11/26/2012 09:32 PM, Steven D'Aprano wrote:
> ... especially when you consider how some other languages implement them.
>
>
> http://twistedoakgames.com/blog/?p=925
>
> [quote]
> Here’s the hypothetical situation: you’re making a flash game. In that
> game users can create named profiles. You store the profiles, keyed by
> their name, so that you ca- OOPS, you just introduced a bug. What’s the
> problem? The dictionary.
> [end quote]
>
>
(facetious)
Whenever someone tries to create a username that happens to conflict
with a pre-existing attribute, just tell them that username is already
taken. Just watch out when your user HasOwnProperty tries to delete his
account.
(/facetious)
Namespaces are great, we should have lots of them. But be very careful
about reusing one without checking to see if it's already inhabited.
When a language design does this sort of thing, it tends to make us
skittish about continuing use of said language.
--
DaveA
More information about the Python-list
mailing list