Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news-transit.tcx.org.uk!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed5.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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'mutable': 0.09; 'received:gator410.hostgator.com': 0.09; '~ethan~': 0.09; 'def': 0.13; 'alex23': 0.16; 'careful,': 0.16; 'pythonic': 0.16; 'shallow': 0.16; 'subject:=': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'arguments': 0.18; 'cc:no real name:2**0': 0.20; 'appropriate': 0.22; '(or': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'function': 0.27; 'lists': 0.28; 'yield': 0.29; 'cc:addr:python.org': 0.29; 'list': 0.32; 'header:User-Agent:1': 0.33; 'bound': 0.37; 'received:76': 0.37; 'allows': 0.38; "i'd": 0.39; "it's": 0.40; 'your': 0.61; 'received:websitewelcome.com': 0.64; 'received:184': 0.67; 'received:69.56': 0.73; '16:50': 0.84; 'camps': 0.84; 'received:gateway15.websitewelcome.com': 0.84; 'yours': 0.85 Date: Thu, 22 Dec 2011 05:20:10 -0800 From: Ethan Furman User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: Rolf Camps Subject: Re: what does 'a=b=c=[]' do References: <18f78d0d-1e70-4c7b-9033-1422e6edb6db@t13g2000yqg.googlegroups.com> <10c62dac-2750-4f08-8962-21952c1c0a0b@v31g2000prg.googlegroups.com> <1324543914.2075.82.camel@puppy> In-Reply-To: <1324543914.2075.82.camel@puppy> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: no X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: c-76-105-214-227.hsd1.or.comcast.net ([192.168.74.5]) [76.105.214.227]:4985 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1324561916 news.xs4all.nl 6871 [2001:888:2000:d::a6]:35627 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:17733 Rolf Camps wrote: > alex23 schreef op wo 21-12-2011 om 16:50 [-0800]: >> I'd say that _is_ the most pythonic way, it's very obvious in its >> intent (or would be with appropriate names). If it bothers you that >> much: >> >> def listgen(count, default=[]): >> for _ in xrange(count): >> yield default[:] >> >> x, y, z = listgen(3) >> > I would change your function to (Python3.x): > > def empty_lists(count): > for _ in range(count): > yield [] While it's good to be careful, default mutable arguments have their place. Alex's versioun allows one to use an already existing list and get shallow copies of it, yours will only create empty lists. a, b, c = listgen([1, 2, 3]) # a, b, & c are bound to different lists ~Ethan~