Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #106817
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask]) |
| Date | Mon, 11 Apr 2016 10:50:36 +1000 |
| Lines | 33 |
| Message-ID | <mailman.1.1460335845.15650.python-list@python.org> (permalink) |
| References | <neelcl$mer$1@gioia.aioe.org> <neeq6v$ruk$1@gioia.aioe.org> <1460333911.3449208.574628345.4B46CD32@webmail.messagingengine.com> <85r3ed2ctn.fsf_-_@benfinney.id.au> <CAPTjJmqXpXvDCJWPypvZodBbJ+hkf_Hizz9Cb-2-4MbLdv=-cQ@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de efFMX23yxKJ3GlLWfZB04gUziu4v89SGmaL37vV9hsDA== |
| Return-Path | <rosuav@gmail.com> |
| 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; 'works.': 0.07; 'subject:question': 0.08; 'cc:addr:python-list': 0.09; '(1,': 0.09; 'literal': 0.09; 'optional': 0.09; 'subject:create': 0.09; 'subject:still': 0.09; 'surrounded': 0.09; 'tuple': 0.09; 'tuple.': 0.09; 'assume': 0.11; 'syntax': 0.13; 'subject: \n ': 0.15; '10:45': 0.16; '2016': 0.16; 'comma': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'one- element': 0.16; 'progression': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:Was': 0.16; 'tuple,': 0.16; 'wrote:': 0.16; 'element': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; '(the': 0.22; 'am,': 0.23; 'slightly': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'followed': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject: [': 0.29; 'code:': 0.29; 'rules': 0.31; 'up.': 0.32; 'problem': 0.33; 'usually': 0.33; 'case,': 0.34; 'correctly': 0.34; 'except': 0.34; 'received:google.com': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'basic': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'wanted': 0.37; 'received:209': 0.38; '(1)': 0.38; 'wrong': 0.38; 'someone': 0.38; 'subject:-': 0.39; 'where': 0.40; 'some': 0.40; "you'll": 0.61; 'show': 0.62; 'different': 0.63; "they're": 0.66; 'chrisa': 0.84; 'progression.': 0.84; 'to:none': 0.91; 'subject:want': 0.93; 'examine': 0.95 |
| 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=Ou/bbF2h3xg26ouYkh+aDGeyrrJ3x2LE1kjXKfyf4ac=; b=XEe9LMBrZC2sjPjLt5s9Ptlf366S5KpBexQW77KXPPb/EYGbgjbZo7npxvi+aXxxV1 ZhSPUCW6P6Q7JnktiOdjapaHWfpSV/hyWXlEf2vKwStkiscp/TaPQdzmMdFA/pRodPmS uspYkn0za6wZoqAP3JgBBJZygHQje17cDYpo6tmxzxBp1vxgZ8Zv+gGAfZAXGDTmdLxJ si2iQU6OJC0vMnJFXdKpTNLGijBk2P9HRgZV5BK9VawAw7K6jis66yeAxA877Nf62LG2 fMWnPlfkWROtJhCYCYuAiog9FncPFA07XmlSD5OOjNrHOEKgU19UWyBqhs4LPwBE2kol 0bvg== |
| 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=Ou/bbF2h3xg26ouYkh+aDGeyrrJ3x2LE1kjXKfyf4ac=; b=iLjBXcX1YY4GSQ5Gq4OtpK0KPHj8HHmuu4rLrXdc52ptnANSXU+I16qjaVjoaqV1GL d7d/lUUgJWNkGS1V8NloO7GDMCmdOfDD1I1ebvC5cz5JFl3AONH3b/y1Etwl0gMj8wY6 p/4pmB65ig8QL9YJdt+lJWRre8EMN3rmUEw/+HZGFZPk0HgMD0FlDfw3VLMFjdYMG9Dv UlwZAvYkw3wcQ4IVVGUcTUlrkcd4QzFoWPMDSaJQf7jtEphzMZ4cJqQWaL6OarwCtYYZ aGkxs9sBVrB+pkF3kjDqSxJLnXsYcqcL2mFqSZAdW1kqszX2jeaZ09kVxHtc2J832R7P Cvug== |
| X-Gm-Message-State | AD7BkJJagVYOFZCiCipzWBGtgxb3ehBRoS1/3y9XEhctR3qO0LboH5lccVqLuFUoiWTQxIkHnBqhOP1aR5DLQA== |
| X-Received | by 10.50.23.80 with SMTP id k16mr15923905igf.94.1460335836916; Sun, 10 Apr 2016 17:50:36 -0700 (PDT) |
| In-Reply-To | <85r3ed2ctn.fsf_-_@benfinney.id.au> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <CAPTjJmqXpXvDCJWPypvZodBbJ+hkf_Hizz9Cb-2-4MbLdv=-cQ@mail.gmail.com> |
| X-Mailman-Original-References | <neelcl$mer$1@gioia.aioe.org> <neeq6v$ruk$1@gioia.aioe.org> <1460333911.3449208.574628345.4B46CD32@webmail.messagingengine.com> <85r3ed2ctn.fsf_-_@benfinney.id.au> |
| Xref | csiph.com comp.lang.python:106817 |
Show key headers only | View raw
On Mon, Apr 11, 2016 at 10:45 AM, Ben Finney <ben+python@benfinney.id.au> wrote: > So the expanation that remains true when you examine it is: People > wanted a literal syntax to create a zero-length tuple. A pair of parens > is that literal syntax, and it's the parens that create the (empty) > tuple. But parens do NOT create a one-element tuple, and that's usually where people trip up. If you show someone this line of code: x = () and ask what x will be, you might get some wrong responses, but you'll get a lot of people correctly deducing that it's a tuple. The problem is that people see this progression: x = () y = (1) z = (1, 2) and assume they're all tuples. A better progression is this: x = () y = (1,) z = (1, 2,) where every element is followed by a comma and every tuple is surrounded by parentheses. In that situation, everything works. There are slightly different rules about which parts are optional (the parens everywhere except the first case, and the last comma everywhere except the second), but this should be the basic form of tuple progression. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Most probably a stupid question, but I still want to ask Fillmore <fillmore_remove@hotmail.com> - 2016-04-10 18:51 -0400
Re: Most probably a stupid question, but I still want to ask Chris Angelico <rosuav@gmail.com> - 2016-04-11 08:58 +1000
Re: Most probably a stupid question, but I still want to ask Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 09:04 +1000
Re: Most probably a stupid question, but I still want to ask Stephen Hansen <me+python@ixokai.io> - 2016-04-10 16:30 -0700
Re: Most probably a stupid question, but I still want to ask Fillmore <fillmore_remove@hotmail.com> - 2016-04-10 20:17 -0400
Re: Most probably a stupid question, but I still want to ask Stephen Hansen <me+python@ixokai.io> - 2016-04-10 17:32 -0700
Re: Most probably a stupid question, but I still want to ask Terry Reedy <tjreedy@udel.edu> - 2016-04-10 21:45 -0400
Re: Most probably a stupid question, but I still want to ask Marko Rauhamaa <marko@pacujo.net> - 2016-04-11 08:41 +0300
one-element tuples [Was: Most probably a stupid question, but I still want to ask] Fillmore <fillmore_remove@hotmail.com> - 2016-04-10 20:13 -0400
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Stephen Hansen <me+python@ixokai.io> - 2016-04-10 17:19 -0700
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Stephen Hansen <me+python@ixokai.io> - 2016-04-10 17:18 -0700
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Chris Angelico <rosuav@gmail.com> - 2016-04-11 10:20 +1000
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Fillmore <fillmore_remove@hotmail.com> - 2016-04-10 20:22 -0400
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Stephen Hansen <me+python@ixokai.io> - 2016-04-10 17:28 -0700
Re: one-element tuples Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 10:31 +1000
Re: one-element tuples Fillmore <fillmore_remove@hotmail.com> - 2016-04-10 20:48 -0400
Re: one-element tuples Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 10:56 +1000
Re: one-element tuples Grant Edwards <invalid@invalid.invalid> - 2016-04-11 14:10 +0000
Re: one-element tuples Fillmore <fillmore_remove@hotmail.com> - 2016-04-11 10:11 -0400
Re: one-element tuples Grant Edwards <invalid@invalid.invalid> - 2016-04-11 14:26 +0000
Re: one-element tuples Ned Batchelder <ned@nedbatchelder.com> - 2016-04-10 18:00 -0700
Re: one-element tuples Stephen Hansen <me+python@ixokai.io> - 2016-04-10 18:07 -0700
Re: one-element tuples "Martin A. Brown" <martin@linux-ip.net> - 2016-04-10 18:08 -0700
Re: one-element tuples Fillmore <fillmore_remove@hotmail.com> - 2016-04-10 23:19 -0400
Re: one-element tuples Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-04-11 09:57 +0300
Re: one-element tuples Larry Hudson <orgnut@yahoo.com> - 2016-04-11 23:01 -0700
Re: one-element tuples Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 11:36 +1000
Re: one-element tuples Fillmore <fillmore_remove@hotmail.com> - 2016-04-10 22:57 -0400
Re: one-element tuples Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 14:10 +1000
Re: one-element tuples Fillmore <fillmore_remove@hotmail.com> - 2016-04-11 00:43 -0400
Re: one-element tuples Stephen Hansen <me+python@ixokai.io> - 2016-04-10 21:54 -0700
Re: one-element tuples Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 15:40 +1000
Re: one-element tuples Rustom Mody <rustompmody@gmail.com> - 2016-04-10 22:07 -0700
Re: one-element tuples BartC <bc@freeuk.com> - 2016-04-11 12:15 +0100
Re: one-element tuples Marko Rauhamaa <marko@pacujo.net> - 2016-04-11 15:12 +0300
Re: one-element tuples Grant Edwards <invalid@invalid.invalid> - 2016-04-11 14:12 +0000
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 10:30 +1000
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] MRAB <python@mrabarnett.plus.com> - 2016-04-11 01:33 +0100
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Dan Sommers <dan@tombstonezero.net> - 2016-04-11 02:22 +0000
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Chris Angelico <rosuav@gmail.com> - 2016-04-11 12:34 +1000
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Chris Angelico <rosuav@gmail.com> - 2016-04-11 10:38 +1000
Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask]) Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 10:45 +1000
Re: Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask]) Chris Angelico <rosuav@gmail.com> - 2016-04-11 10:50 +1000
Re: Parens do create a tuple Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 10:57 +1000
Re: Parens do create a tuple Chris Angelico <rosuav@gmail.com> - 2016-04-11 11:04 +1000
Re: Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask]) Stephen Hansen <me@ixokai.io> - 2016-04-10 18:03 -0700
Re: Parens do create a tuple (was: one-element tuples [Was: Most probably a stupid question, but I still want to ask]) Tim Chase <python.list@tim.thechases.com> - 2016-04-10 19:52 -0500
Re: Parens do create a tuple Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 11:41 +1000
Re: Parens do create a tuple Steven D'Aprano <steve@pearwood.info> - 2016-04-11 12:32 +1000
Re: Parens do create a tuple Random832 <random832@fastmail.com> - 2016-04-10 22:51 -0400
Re: Parens do create a tuple Steven D'Aprano <steve@pearwood.info> - 2016-04-11 14:08 +1000
Re: Parens do create a tuple Random832 <random832@fastmail.com> - 2016-04-11 01:27 -0400
Re: Parens do create a tuple Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-04-11 18:01 +1000
Re: Parens do create a tuple Random832 <random832@fastmail.com> - 2016-04-11 09:42 -0400
Re: Parens do create a tuple Chris Angelico <rosuav@gmail.com> - 2016-04-11 13:02 +1000
Re: Parens do create a tuple Ben Finney <ben+python@benfinney.id.au> - 2016-04-11 14:08 +1000
Re: Parens do create a tuple Chris Angelico <rosuav@gmail.com> - 2016-04-11 11:51 +1000
Re: Parens do create a tuple Steven D'Aprano <steve@pearwood.info> - 2016-04-11 12:57 +1000
Re: one-element tuples [Was: Most probably a stupid question, but I still want to ask] Tim Chase <python.list@tim.thechases.com> - 2016-04-10 19:46 -0500
Re: Most probably a stupid question, but I still want to ask Steven D'Aprano <steve@pearwood.info> - 2016-04-11 11:50 +1000
Re: Most probably a stupid question, but I still want to ask Fillmore <fillmore_remove@hotmail.com> - 2016-04-10 22:48 -0400
Re: Most probably a stupid question, but I still want to ask Steven D'Aprano <steve@pearwood.info> - 2016-04-11 13:54 +1000
Re: Most probably a stupid question, but I still want to ask Fillmore <fillmore_remove@hotmail.com> - 2016-04-11 00:03 -0400
Re: Most probably a stupid question, but I still want to ask Stephen Hansen <me+python@ixokai.io> - 2016-04-10 21:46 -0700
Re: Most probably a stupid question, but I still want to ask Rustom Mody <rustompmody@gmail.com> - 2016-04-10 22:18 -0700
Re: Most probably a stupid question, but I still want to ask Stephen Hansen <me+python@ixokai.io> - 2016-04-10 22:42 -0700
Re: Most probably a stupid question, but I still want to ask Rustom Mody <rustompmody@gmail.com> - 2016-04-10 23:57 -0700
Re: Most probably a stupid question, but I still want to ask Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-04-11 17:50 +1000
csiph-web