Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'value,': 0.04; '(although': 0.05; 'initialize': 0.07; 'many)': 0.09; 'am,': 0.12; 'agreed,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'instance:': 0.16; 'operator.': 0.16; 'rhs': 0.16; 'syntax': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'defined': 0.19; 'header:In-Reply-To:1': 0.22; '(or': 0.23; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'aug': 0.24; 'statement': 0.25; 'function': 0.27; 'right.': 0.28; 'message-id:@mail.gmail.com': 0.29; 'lines': 0.30; 'times.': 0.30; 'separately': 0.30; 'subject:?': 0.31; 'chris': 0.32; 'expression': 0.32; 'minor': 0.32; 'proposed': 0.32; 'to:addr:python-list': 0.33; 'file.': 0.34; '17,': 0.34; 'assignment': 0.34; 'object': 0.35; 'but': 0.37; 'something': 0.37; 'some': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'might': 0.40; 'more': 0.60; 'easily': 0.61; 'evaluate': 0.71; 'subject:one': 0.77; 'subject:value': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=de2etW7uAaVOgHTB6FEY0demPbNDAEtc59PHdLnIFKg=; b=M8xFQZTUZByguyYZcfi1q8JI59OmSRZAmChPpUjHo4VZd09YMZxUQUWp4JYkI6ybS5 uzq6lt7u0v1lWTFqsWUA2yreTDrih5FffkZcaieRNbktVG8fqL+NSgryKu2s85qVt4l6 6wJQ+EtRZfMEm/6moNMl7Av11WUJ6Randl9hI= MIME-Version: 1.0 In-Reply-To: References: <16ea4848-db0c-489a-968c-ca40700f5806@m5g2000prh.googlegroups.com> <7f30e39b-4e4f-4426-b819-b4670871d199@df3g2000vbb.googlegroups.com> Date: Wed, 17 Aug 2011 10:45:24 +0100 Subject: Re: Syntactic sugar for assignment statements: one value to multiple targets? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313574326 news.xs4all.nl 23940 [2001:888:2000:d::a6]:49471 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11673 On Wed, Aug 17, 2011 at 10:26 AM, gc wrote: > On Aug 17, 3:13=A0am, Chris Angelico wrote: > >> Minor clarification: You don't want to initialize them to the same >> value, which you can do already: >> >> a=3Db=3Dc=3Dd=3De=3Ddict() > > Right. Call the proposed syntax the "instantiate separately for each > target" operator. =A0(It can be precisely defined as a * on the RHS of a > one-into-many assignment statement--i.e. an assignment statement with > 1 object on the RHS and more than 1 on the LHS). > Agreed, but there's no requirement for it to be instantiating something (although that will be common). "dict()" is an expression that you want to evaluate five (or however many) times. It might just as easily be some other function call; for instance: head1,head2,head3=3Dfile.readline() to read three lines from a file. Or it mightn't even be a function call per= se. ChrisA