Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Chris Angelico Newsgroups: comp.lang.python Subject: Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Date: Mon, 11 Apr 2016 10:38:33 +1000 Lines: 21 Message-ID: References: <570AF0C6.7020007@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de g8ymwHH4/AyapC6CgCUPAwwDoxnAS5VWc+1GqxA+xjsw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'mrab': 0.05; 'calls.': 0.07; 'plenty': 0.07; 'subject:question': 0.08; 'cc:addr:python- list': 0.09; 'assigning': 0.09; 'subject:still': 0.09; 'tuple': 0.09; 'tuple.': 0.09; 'unpack': 0.09; 'syntax': 0.13; 'subject: \n ': 0.15; '2016': 0.16; 'constructs': 0.16; 'describing': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'magic': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Was': 0.16; 'syntactic': 0.16; 'targets:': 0.16; 'wrote:': 0.16; '(in': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'arguments': 0.22; 'am,': 0.23; 'passing': 0.23; 'header:In-Reply-To:1': 0.24; 'feature': 0.24; 'mon,': 0.24; 'packaging': 0.27; 'parameters': 0.27; 'message- id:@mail.gmail.com': 0.27; 'specify': 0.27; 'function': 0.28; 'values': 0.28; 'subject: [': 0.29; 'certain': 0.31; 'case,': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'instead': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'keyword': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'names': 0.38; 'subject:-': 0.39; 'where': 0.40; 'some': 0.40; 'making': 0.62; 'chrisa': 0.84; 'to:none': 0.91; 'subject:want': 0.93; 'this;': 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; bh=uIOcAdEcDltr1WWhjKVPpO5JqytvXPeFSZF/HVTvC2U=; b=DS/nrq0i8/SnB0DxDMI/FsX2regsdqJZ918Rr8xE309r8NQZgOBRL4OTNBhzsLmxVl 4hYgBg2NerXpjkfec/B7VXp72qWyoOsNLQRcVXqI2jbYuMdYCsU06WaCLCPLdVn2m21c izHh34K7s+lSSZWTAM7rOqqIPnqiHr9Z1I1tPaj0S9sJmnFt4QB3l3f7oiEQCyTYjizR 4LuKyMBuFtLYuuset45mEv5n6BxrPZpabeaQaMhpXLhisI79WnFdiNQ0Cku57lFT1maf vo4r8GZFpICugRgE0c1XXhjWf7mXQIqabJQjWY02cBkaeVLscnWR68DcXBHG1rWvespv w+Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=uIOcAdEcDltr1WWhjKVPpO5JqytvXPeFSZF/HVTvC2U=; b=e2j3X/DRHlkdk9mqv0uLtBC4NBN6SDfmgXaDoy6NfEiD0Rm8idLsPjywLjyEBdD4Hn 5kRLij/IzNbYuLWawkeOj3n2qMLLcaPqTCfCdY8CFtjFdMreTOmsmTLmnwkBulsYicHr 20LdR15KTgNcH5cICYc9+TJdMQ1z984vNQzZL2CEJtw+Wk3jYNMQHIyGpwqD4ok7X1Kp vRPOHtTmsfmeLhAsW+P1sYcIIy93AbDKAOrwu+G/X9MMDVaWogGTcix7HgLwcNYC51uY 3rdRz3ujKyUfoVhTSuncnNGIn0p4Eu9tqrGWazbNPswLschwe1f9vnFemzbtNacQ90jh H2cg== X-Gm-Message-State: AD7BkJLUMcype9WOTNFtf3ZMlGqHdQbA4EydyAsHYvnL4cSr4ugf4qb3JDGVIqK8GyE47nIm1FXHS/WUIwdvkw== X-Received: by 10.51.17.34 with SMTP id gb2mr15291931igd.13.1460335113599; Sun, 10 Apr 2016 17:38:33 -0700 (PDT) In-Reply-To: <570AF0C6.7020007@mrabarnett.plus.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <570AF0C6.7020007@mrabarnett.plus.com> Xref: csiph.com comp.lang.python:106814 On Mon, Apr 11, 2016 at 10:33 AM, MRAB wrote: > For example, object are passed into a function thus: > > f(x, y) > > (In reality, it's making a tuple and then passing that in.) Actually that's not the case; certain syntactic constructs allow you to specify multiple of something, without packaging them up into a tuple. Function arguments and parameters are like this; otherwise keyword arguments would have to be some kind of magic syntax in tuples, instead of being a feature of function calls. But there are plenty of situations where what you're describing _is_ the case, such as assigning multiple values to multiple targets: # Package up y and x into a tuple # Then unpack the tuple into two names x, y = y, x ChrisA