Builtin dict should be callable, since a dict defines a function

Bengt Richter bokr at oz.net
Thu Dec 19 22:52:01 EST 2002


On Thu, 19 Dec 2002 19:21:53 -0800, Erik Max Francis <max at alcyone.com> wrote:

>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
IMO various uses are red herrings. What needs to be justified is an
existing limitation on uniform passing of references to standard objects
that implement the same functionality, just for lack of a trivial alternative
compatible interface.


>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.
That's not really the issue ;-)
>
>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 don't see a commonality in the abstract?

>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_.
No one would be forced to use an additional interface that doesn't exit now ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list