Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: Accessing container's methods Date: Tue, 8 Dec 2015 09:02:33 +1100 Lines: 18 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de XZxhMvHux3xiJmF6mEAUqgjzlzaJSXrtwdRIMlRCBKJQ== Return-Path: 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: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:100114 On Tue, Dec 8, 2015 at 8:38 AM, Terry Reedy 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