On 19 Dec, 05:24, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > En Tue, 18 Dec 2007 09:15:12 -0300, English, Mark <[EMAIL PROTECTED]> > escribió: > > > > >>>> try: set > >>>> except NameError: from sets import Set as set > >>>> class myset_fails(set): pass > >>>> class myset_works(set): > >>>> def __getitem__(self): pass > >>>> s = set() > >>>> fails = myset_fails() > >>>> works = myset_works() > >>>> import operator > >>>> operator.isSequenceType(s) #Not what I expected > > False > >>>> operator.isSequenceType(fails) #Not what I expected either > > False > >>>> operator.isSequenceType(works) #A hint at what isSequenceType does ? > > True > > > Are sets not sequences ? I didn't think the isSequenceDisclaimer gave > > false negatives. > > No, sets aren't sequences, as they have no order. Same as dicts, which > aren't sequences either.
Oops. I was under the misapprehension that they were sequences in that they were sequential but of unknown ordering e.g. for x in set([someobject, someotherobject, ...]) always iterates in the same order Anywho, now I know. Thanks. Is there a short Pythonic way to determine whether an object is iterable (iteratable ??) that I haven't thought of (getattr(obj, '__iter__') ?). Would operator.isIterable() be at all a useful addition ? (And what did I do wrong when I posted my original post that I can't see it in groups.google) -- http://mail.python.org/mailman/listinfo/python-list