[Python-ideas] issubclass(collections.OrderedDict, collections.Sequence)

Guido van Rossum guido at python.org
Mon Oct 6 01:15:45 CEST 2014


OK, so collections.Ordered would be a subclass of Iterable that adds no new
methods but makes a promise about the author's intent.

But what kind of use could a program make of this? The only things I can
think of would have to be combined with some other specific container type
that isn't always ordered (Sequence is ordered, Set and Mapping aren't). I
can think of plenty of situations where it would be useful to say "use an
OrderedDict, otherwise X will happen", but I can't think of a case where I
could say "use any container type you like as long as it is Ordered".

What was your use case? Do you have one? Or are you just interested in
asking questions?

On Sun, Oct 5, 2014 at 3:07 PM, Ram Rachum <ram at rachum.com> wrote:

> Yep, Ed said exactly what I meant.
> On Oct 6, 2014 1:05 AM, "Ed Kellett" <edk141 at gmail.com> wrote:
>
>> I think the definition of ordered here would be that the container's
>> iteration order carries any meaning (compare: dicts and sets' having
>> iteration order is an incidental effect of one thing having to be
>> iterated out first, and one shouldn't depend on that order; lists and
>> ordereddicts' having iteration order is deliberate).
>>
>> I don't think there's a mathematical definition possible - it's just a
>> question of whether whoever wrote the class left the iteration order
>> documented or unspecified.
>>
>>
>> edk
>>
>


-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20141005/650134f9/attachment.html>


More information about the Python-ideas mailing list