Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!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.033 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'subject:Python': 0.06; 'tries': 0.07; 'counting': 0.09; 'iterate': 0.09; 'exists,': 0.16; 'iterable': 0.16; 'wrote:': 0.18; 'items.': 0.19; 'not,': 0.20; 'feb': 0.22; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'that.': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'subject: (': 0.35; 'received:google.com': 0.35; 'otherwise.': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'back': 0.62; 'subject:! ': 0.74; '2015': 0.84; 'subject:!)': 0.84; 'walking': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=T67k1HHqwXrU19dBO2ivQJ1T/XY1VUX9v3xDGZrEq7U=; b=YF61kE8Wm0Uztus8hQUOoarlhklTZGFeg0qdImLAzcaZwojyZw0OqbzXxu6ykAobbI TbmIKu4xTTzd7qSKzDAJ+Kup3WDwO0OHJhFFlZxHtIOSEGTrQ8Q/thW+FHU85MOIs5Fz y/z2CZVfKcHKM5Pd8TRVJB89F7CQyvtMEoJxNW9X7AzZsytrdPTEK+KF6r/PqUhdqEJM c3j8m3tAc7YV7GFGe/wf07t+45Uu6KkkJZ/+A294crw/i4xVd+chTGWUWmaXGyGejixz Iec10DhzpLPouJsiBtQCOqXkHolg0jbzVwKziF8T+W6jjkaXJaqCEHRuSiWrErd86eTo VxXg== X-Received: by 10.68.242.200 with SMTP id ws8mr23864297pbc.138.1422811946114; Sun, 01 Feb 2015 09:32:26 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <54ce5a92$0$12996$c3e8da3$5496439d@news.astraweb.com> References: <54c07d04$0$13012$c3e8da3$5496439d@news.astraweb.com> <54c1ccc8$0$13005$c3e8da3$5496439d@news.astraweb.com> <54c6d7c2$0$12992$c3e8da3$5496439d@news.astraweb.com> <54c83ab4$0$12982$c3e8da3$5496439d@news.astraweb.com> <54ca583e$0$13005$c3e8da3$5496439d@news.astraweb.com> <54ccc2fc$0$13009$c3e8da3$5496439d@news.astraweb.com> <54cd9a7a$0$12984$c3e8da3$5496439d@news.astraweb.com> <54ce526a$0$13012$c3e8da3$5496439d@news.astraweb.com> <54ce5a92$0$12996$c3e8da3$5496439d@news.astraweb.com> From: Ian Kelly Date: Sun, 1 Feb 2015 10:31:45 -0700 Subject: Re: dunder-docs (was Python is DOOMED! Again!) To: Python Content-Type: text/plain; charset=UTF-8 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422811948 news.xs4all.nl 2959 [2001:888:2000:d::a6]:57751 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:85012 On Sun, Feb 1, 2015 at 9:55 AM, Steven D'Aprano wrote: > Steven D'Aprano wrote: > >> len tries to call __len__ if it exists, and if not, it tries walking the >> iterable counting items. > > Hmmm, I may have mis-remembered that. Perhaps I'm thinking of Ruby. I think you just got it backward. iter will call __iter__ if it exists, and will try to fall back on __len__ and __getitem__ to iterate otherwise.