Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder3.xlned.com!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; 'essentially': 0.04; 'method.': 0.05; 'builtin': 0.07; 'reason,': 0.07; 'try:': 0.07; '-1,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'def': 0.10; 'thread': 0.11; '-1):': 0.16; 'agree.': 0.16; 'expression.': 0.16; 'iterator,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'substituted': 0.16; 'surprising': 0.16; 'yield': 0.17; 'jan': 0.18; 'equivalent': 0.20; 'raise': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'common': 0.26; 'header:X-Complaints-To:1': 0.28; 'trouble': 0.28; 'skip:_ 10': 0.29; 'returned': 0.30; 'getting': 0.33; 'to:addr:python-list': 0.33; 'list': 0.35; 'received:org': 0.36; 'except': 0.36; 'enough': 0.36; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'list,': 0.39; 'short': 0.39; 'header:Received:5': 0.40; 'think': 0.40; 'range': 0.60; 'more': 0.63; 'premise': 0.84; 'received:fios.verizon.net': 0.84; 'tem': 0.84; 'worth,': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: LangWart: Method congestion from mutate multiplicty Date: Sun, 10 Feb 2013 03:39:21 -0500 References: <680e50a4-6569-49cf-b369-0be450545d50@googlegroups.com> <5115c455$0$6574$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360485575 news.xs4all.nl 6851 [2001:888:2000:d::a6]:56541 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38560 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. The need for the short form was thought common enough to be worth, *on balance*, a new builtin name. It is not surprising that not all agree. Reversed(iterable) is more complicated because it returns an iterator, not a list, and looks for a class-specific __reversed__ method. I think it is more or less equivalent to the following: def _rev_iter(seq, n): for i in range(n-1, -1, -1): # many people have trouble getting the range right yield seq[i] def reversed(iterable): try: return iterable.__reversed__() except AttributeError: try: itlen = iterable.__len__ iterable.__getitem__ return _rev_iter(iterable, itlen) except AttributeError: raise TypeError("argument to reversed() must be a sequence") Even if list mutation methods returned the list, which they do not and for good reason, reversed(it) is not the same as list(it).reverse(). So that part of the premise of this thread is wrong. -- Terry Jan Reedy