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

Stephen J. Turnbull stephen at xemacs.org
Wed Oct 8 03:09:45 CEST 2014


Ram Rachum writes:

 > Yep, this is what I meant.

(And you'll answer in this precision in the future, of course. :)

 > On Tue, Oct 7, 2014 at 11:28 PM, <random832 at fastmail.us> wrote:

 > > i.e. (pseudo-code, and probably not the order in which these tests would
 > > normally take place)
 > >
 > > if the elements of object A are a subset those of list B:
 > >     if object A has a meaningful order:
 > >         if the order of object A's elements is the same as that of list B:

But this requires a comparison of the two orders, and "ordering
relation" is not a type available in the stdlib.  So I don't see how
you propose to do this comparison.  This is why you need concrete
examples, preferably with running code.

OTOH, in the kind of context you're working with, I'd probably use a
specific ordered type to contain the combinations (which might be a
tree or other implicitly ordered type, not necessarily a Sequence)
rather than generic lists etc., and define __eq__ on it.  The need for
collections.Ordered evaporates!




More information about the Python-ideas mailing list