Builtin dict should be callable, since a dict defines a function
Erik Max Francis
max at alcyone.com
Thu Dec 19 22:21:53 EST 2002
Bengt Richter wrote:
> You can pass a reference to a dict to something that expects a
> function,
> e.g., a sort.
This has me puzzled. Are you really suggesting that it would be useful
to represent a sorting as a dictionary whose keys are 2-tuples of every
possible combination of the items (thus requiring that they be
immutable), and that every value is one of -1, 0, or +1 defined in such
a way that they define a well-ordering? Does that _really_ justifying
defining a callable interface for dictionaries, when if you were to end
up with such a bizarre situation, you could simply do
D = {...}
L.sort(lambda x, y, D=D: D((x, y)))
You have really lost me on the possible utility of such a thing.
Mappings are mappings. Callables are callables. Folding them into the
same thing doesn't make any sense to me. In weird corner cases where
you really _do_ want to do such a thing, you're much better off doing it
with a wrapper. I don't see any justifiable reason to force that
conjoining of different interfaces on _everyone_.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/ \ I'm trying to forget / But I can't act as if we never met
\__/ Chante Moore
PyUID / http://www.alcyone.com/pyos/uid/
A module for generating "unique" IDs in Python.
More information about the Python-list
mailing list