Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #100114

Re: Accessing container's methods

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Subject Re: Accessing container's methods
Date Tue, 8 Dec 2015 09:02:33 +1100
Lines 18
Message-ID <mailman.36.1449525755.12405.python-list@python.org> (permalink)
References <dcm0c2Fi2ktU1@mid.individual.net> <n44ua0$oq2$1@ger.gmane.org>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de XZxhMvHux3xiJmF6mEAUqgjzlzaJSXrtwdRIMlRCBKJQ==
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.022
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'def': 0.13; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'subject:Accessing': 0.16; 'wrote:': 0.16; '2015': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'am,': 0.23; 'dec': 0.23; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; '(although': 0.29; 'skip:[ 10': 0.31; 'tue,': 0.34; 'received:google.com': 0.35; 'received:209.85': 0.36; 'faster': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'self': 0.38; 'chrisa': 0.84; 'to:none': 0.91; 'favour': 0.93
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; bh=app7Ymcqz8+GRfexh2i8K0FQO1XxRC/4FtWFC4/Oa1k=; b=BMaDRqmWcGOgogmiK6sH1BmnKGtar66TBTim7Q+UCvVA+w4eCrnCQ36JKxs7OpqwUM RBWkJ4BeoSDp0kBQC+yToZD/xXKbjoT+1W2hbkOjfzaxKtjkJB/zhoByD5RQsldcizk6 Ba51xoP6F4ldd7PTJsdj37/MHRo7TgReqqyK61h3/oarkBBIatkYWdVLtuslzs67WqZf 24Lxf3B9Tbch76F3nZ/pH8uDK6pwzlewdDjHxBLmJB0NASiBrfIZpxpNYlXp6Ob4T+vL Y0zElakcRDmEv9cW2mHQvruGLBav+RxTMbOrr90wFHcN1qzy6knRItIOWC/YFrcb0/Ii Rlsw==
X-Received by 10.50.20.8 with SMTP id j8mr12287664ige.94.1449525753264; Mon, 07 Dec 2015 14:02:33 -0800 (PST)
In-Reply-To <n44ua0$oq2$1@ger.gmane.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Xref csiph.com comp.lang.python:100114

Show key headers only | View raw


On Tue, Dec 8, 2015 at 8:38 AM, Terry Reedy <tjreedy@udel.edu> wrote:
>>    def list_actors( self ):
>>      h=[]
>>      for n in self.actors:
>>        h.append( n.get_name() )
>>      return h
>
>
> return list(self.actors)  # or perhaps even faster
> return self.actors[:]

Not identical semantics. This is a use-case for a comprehension:

return [n.get_name() for n in self.actors]

(although I would eschew the getter in favour of just "n.name")

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Accessing container's methods Tony van der Hoff <tony@vanderhoff.org> - 2015-12-07 18:10 +0000
  Re: Accessing container's methods Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2015-12-07 18:21 +0000
  Re: Accessing container's methods Michael Torrie <torriem@gmail.com> - 2015-12-07 11:36 -0700
    Re: Accessing container's methods Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-07 20:03 +0100
  Re: Accessing container's methods Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-07 19:46 +0100
  Re: Accessing container's methods Peter Otten <__peter__@web.de> - 2015-12-07 19:59 +0100
  Re: Accessing container's methods Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-07 12:33 -0700
  Re: Accessing container's methods Terry Reedy <tjreedy@udel.edu> - 2015-12-07 16:38 -0500
  Re: Accessing container's methods Chris Angelico <rosuav@gmail.com> - 2015-12-08 09:02 +1100
  Re: Accessing container's methods Erik <python@lucidity.plus.com> - 2015-12-07 23:47 +0000
    Re: Accessing container's methods Tony van der Hoff <tony@vanderhoff.org> - 2015-12-08 12:35 +0000
    Re: Accessing container's methods [solved] Tony van der Hoff <tony@vanderhoff.org> - 2015-12-08 13:46 +0000
    Re: Accessing container's methods Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-08 20:02 +0100
      Re: Accessing container's methods Vincent Vande Vyvre <vincent.vande.vyvre@telenet.be> - 2015-12-08 20:54 +0100
        Re: Accessing container's methods Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-08 23:51 +0100
      Re: Accessing container's methods Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-08 20:30 +0000
        Re: Accessing container's methods Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-12-08 23:52 +0100
          Re: Accessing container's methods Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-12-08 22:59 +0000
      Re: Accessing container's methods Erik <python@lucidity.plus.com> - 2015-12-08 22:37 +0000
      Re: Accessing container's methods Ian Kelly <ian.g.kelly@gmail.com> - 2015-12-08 16:41 -0700
      Re: Accessing container's methods Chris Angelico <rosuav@gmail.com> - 2015-12-09 12:04 +1100

csiph-web