Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'value,': 0.04; 'initialize': 0.07; 'initialized': 0.09; 'am,': 0.12; 'evaluates': 0.16; 'expression.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'syntax': 0.16; 'wrote:': 0.16; 'wed,': 0.17; 'once,': 0.18; "aren't": 0.21; 'maybe': 0.21; 'header:In-Reply-To:1': 0.22; 'aug': 0.24; 'message- id:@mail.gmail.com': 0.29; 'asking': 0.29; 'subject:?': 0.31; 'list': 0.32; 'cases': 0.32; 'expression': 0.32; 'minor': 0.32; 'there': 0.33; 'to:addr:python-list': 0.33; '(as': 0.34; '17,': 0.34; 'similar': 0.35; 'are.': 0.37; 'variables': 0.37; 'but': 0.37; 'something': 0.37; 'think': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40; 'subject:one': 0.77; 'subject:value': 0.84; 'times;': 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; bh=CXxE4nPbhNP2OnnWqGNsKde02f1bBwPY+IPtYRXUsNE=; b=OthOAPWcvUAbiT6js3/oR+2MpgtJ9iSOLNdLT12wRVYlRNlC/Awlu1W5L8kZkuNB9D DcVeCYGAewh+GpB14cNIYiCCL9DcL4WO+4TRGziZ3g9RqziS1HjVQULjVwforF/J31bQ X+wGd5jSjvPT4FSOODxYRsClLIeUUYn/UVzjg= MIME-Version: 1.0 In-Reply-To: <7f30e39b-4e4f-4426-b819-b4670871d199@df3g2000vbb.googlegroups.com> References: <16ea4848-db0c-489a-968c-ca40700f5806@m5g2000prh.googlegroups.com> <7f30e39b-4e4f-4426-b819-b4670871d199@df3g2000vbb.googlegroups.com> Date: Wed, 17 Aug 2011 08:13:49 +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 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1313565232 news.xs4all.nl 23861 [2001:888:2000:d::a6]:46355 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:11659 On Wed, Aug 17, 2011 at 1:14 AM, gc wrote: > Perfectly reasonable request! Maybe there aren't as many cases when > multiple variables need to be initialized to the same value as I think > there are. > Minor clarification: You don't want to initialize them to the same value, which you can do already: a=b=c=d=e=dict() You want to initialize them each to a fresh evaluation of the same expression. What you're asking for is a syntax that writes an expression once, but evaluates it many times; I think it's going to work out something very similar to a list comprehension (as has been mentioned). ChrisA