Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'syntax': 0.03; 'essentially': 0.04; 'explicitly': 0.04; 'method.': 0.05; 'line:': 0.07; 'reason,': 0.07; 'python': 0.09; 'terry': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'thread': 0.11; 'modification': 0.15; 'bit.': 0.16; 'cleanly': 0.16; 'expression.': 0.16; 'in-place': 0.16; 'iteration': 0.16; 'iterator': 0.16; 'iterator,': 0.16; 'iterators': 0.16; 'operation.': 0.16; 'reedy': 0.16; 'sequence:': 0.16; 'substituted': 0.16; 'wrote:': 0.17; 'handles': 0.18; 'implicit': 0.22; 'object.': 0.22; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'skip:" 20': 0.26; 'loop,': 0.29; 'oop': 0.29; 'proposing': 0.29; 'returned': 0.30; 'could': 0.32; 'handle': 0.33; 'received:google.com': 0.34; 'or,': 0.34; 'list': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'being': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'list,': 0.39; 'more': 0.63; 'behavior': 0.64; 'taking': 0.65; '2013': 0.84; 'idiom': 0.84; 'premise': 0.84; 'tem': 0.84 X-Received: by 10.49.60.40 with SMTP id e8mr783024qer.40.1360521914182; Sun, 10 Feb 2013 10:45:14 -0800 (PST) Newsgroups: comp.lang.python Date: Sun, 10 Feb 2013 10:45:13 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=70.196.111.103; posting-account=h3aEwQoAAACiuqX-oR3gvCVFm8lLHoWj References: <680e50a4-6569-49cf-b369-0be450545d50@googlegroups.com> <5115c455$0$6574$c3e8da3$5496439d@news.astraweb.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 70.196.111.103 MIME-Version: 1.0 Subject: Re: LangWart: Method congestion from mutate multiplicty From: Rick Johnson To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Cc: python-list@python.org 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: , Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360522696 news.xs4all.nl 6886 [2001:888:2000:d::a6]:41733 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38597 On Sunday, February 10, 2013 2:39:21 AM UTC-6, Terry Reedy wrote: > While it is true that sorted(iterable) is essentially > > def sorted(iterable): > tem = list(iterable) > tem.sort > return tem > > the body is not an expression and cannot be substituted in an > expression. Yes but the body can be compressed to this single line: "list(iterable).sort()" > Reversed(iterable) is more complicated because it returns an iterator, > not a list, and looks for a class-specific __reversed__ method. > [...] Well if you're taking the position that iterators are difficult to create i say you are exaggerating a bit. Using the for loop: py> for LOCALVAR in SEQUENCE: ... do_something we can get the iterator for free. If however you want to control the iteration /without/ being locked into a loop, you can explicitly call: py> iter(seq) Or, if you prefer methods over global functions: py> seq.__iter__() Or, if python employed /true/ OOP paradigm: py> Iterator(seq) > Even if list mutation methods returned the list, which they do not and > for good reason, I am not proposing that in-place modification return the object. > reversed(it) is not the same as list(it).reverse(). So > that part of the premise of this thread is wrong. Well, it's not the same /now/, because of how Python handles this operation. The status quo is to encourage the implicit idiom over the explicit, however, this behavior could be optimized to cleanly handle /explicit/ syntax only.