Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.044 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'formatting': 0.09; 'subject:iterable': 0.09; 'cc:addr:python-list': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'iterable': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'value.': 0.19; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'asking': 0.27; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'wonder': 0.29; 'message-id:@mail.gmail.com': 0.30; 'fixing': 0.31; 'sep': 0.31; 'this.': 0.32; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'google': 0.35; 'there': 0.35; 'ordered': 0.36; 'next': 0.36; 'subject:?': 0.36; 'pm,': 0.38; "you're": 0.61; 'subject:there': 0.68; 'ordered.': 0.84; 'subject:check': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=a3N4xGfHgcWXcZyYXcxvJ/0DlvzXn1FUEmcgmazxaJo=; b=aVJYXdoeLLoHsPAF7c5udii1m959cQZz8AaB32CXkI4OSh4gnATTIZwIRCbD1zRCrq fxmjuT3/TUC3XEjN+mZXxypvVTVApoHmDrk7IfIvKjg9hYrDPXtQ5Wvh8oOr6Bhuxe7d 97Y01iSEmzm4JKsTce1c4EqmkxiQ4V/3rrIKLbJNZSo50zqLVsKhTGhnS5d6D47TD77b RyPVc6PTX398Z0Xm1syPMlqiAgSVVjbzSXbiPNT4MLFovkQo8X26LK5pfWe7Iok/LtxY pJkpHekGadwm7OuROosbv5jk0b4dEGGhSusGLxXoh0z9FIUljog+61f2OLAzwo78LOSB 8gzg== MIME-Version: 1.0 X-Received: by 10.43.94.7 with SMTP id bw7mr4536126icc.26.1411042242240; Thu, 18 Sep 2014 05:10:42 -0700 (PDT) In-Reply-To: References: Date: Thu, 18 Sep 2014 22:10:42 +1000 Subject: Re: Is there a canonical way to check whether an iterable is ordered? From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1411042251 news.xs4all.nl 2833 [2001:888:2000:d::a6]:39378 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78011 On Thu, Sep 18, 2014 at 9:55 PM, cool-RR wrote: > My function gets an iterable of an unknown type. I want to check whether = it's ordered. I could check whether it's a `set` or `frozenset`, which woul= d cover many cases, but I wonder if I can do better. Is there a nicer way t= o check whether an iterable is ordered or not? > An iterable is always ordered. You call next() and you get the next value. Are you asking if there's a way to find out if the order matters? Not easily. What's your use-case? Why do you need to know? Also, you're still using Google Groups, which means your formatting is b0rked. Please can you use something better, or else look into fixing this. ChrisA