Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'interpreter': 0.05; 'method.': 0.07; 'method,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Why': 0.09; 'python': 0.11; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.18; 'header:User- Agent:1': 0.23; 'received:comcast.net': 0.24; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; "doesn't": 0.30; '>>>>': 0.31; 'invoke': 0.31; 'this.': 0.32; 'subject:the': 0.34; 'but': 0.35; 'curious': 0.36; 'object,': 0.36; 'method': 0.36; 'skip:[ 10': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'deal,': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Ned Batchelder Subject: Re: Why is the interpreter is returning a 'reference'? Date: Mon, 17 Feb 2014 12:08:34 -0500 References: <9b80c233-ad31-44c8-8a6e-9002ab11bd0d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: c-50-133-228-126.hsd1.ma.comcast.net User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 In-Reply-To: <9b80c233-ad31-44c8-8a6e-9002ab11bd0d@googlegroups.com> 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392656931 news.xs4all.nl 2830 [2001:888:2000:d::a6]:56156 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66611 On 2/17/14 12:00 PM, Nir wrote: >>>> k = ['hi','boss'] >>>> >>>> k > ['hi', 'boss'] >>>> k= [s.upper for s in k] >>>> k > [, ] > > Why doesn't the python interpreter just return > ['HI, 'BOSS'] ? > > This isn't a big deal, but I am just curious as to why it does this. > You have to invoke s.upper, with parens: k = [s.upper() for s in k] In Python, a function or method is a first-class object, so "s.upper" is a reference to the method, "s.upper()" is the result of calling the method. -- Ned Batchelder, http://nedbatchelder.com