| Deutsch English Français Italiano |
|
<tuples-20231125220335@ram.dialup.fu-berlin.de> View for Bookmarking (what is this?) Look up another Usenet article |
Path: eternal-september.org!news.eternal-september.org!feeder3.eternal-september.org!eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Silly/crazy problem with sqlite
Date: 25 Nov 2023 21:12:08 GMT
Organization: Stefan Ram
Lines: 37
Expires: 1 Dec 2024 11:59:58 GMT
Message-ID: <tuples-20231125220335@ram.dialup.fu-berlin.de>
References: <gre73k-ib223.ln1@esprimo.zbmc.eu> <g2g73k-k2523.ln1@esprimo.zbmc.eu> <comma-20231125104453@ram.dialup.fu-berlin.de> <6re93k-bfu53.ln1@esprimo.zbmc.eu>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de tpNNAMIbeadSDjwPCCS9ogw0E04kakDVmG4BRFLKaQNGLG
Cancel-Lock: sha1:UaJ5vbzBskURHqdgnsoaLI28oRo= sha256:mb3vtqfOEsRWLllojCk6ds5NeHqjlYAlX21vm1H0DiE=
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
Chris Green <cl@isbd.net> writes:
>The error message could be a bit more helpful too, maybe one of those
>"... did you mean ....?" ones could point one in the right direction.
|>>> a = 1, 2, 3
|>>> print( a )
|(1, 2, 3)
In the first line, one can see that tuples are written with commas.
But when a tuple is printed, Python add parentheses. This may have
led people to believe that parentheses mark tuples.
Moreover, the empty tuple can be written as "()", i.e., a pair of
parentheses without a comma. In this special case, the parentheses
really are related to the tupleness of the expression!
However, a single expression (and nothing more) in parentheses
does not evaluated to a tuple (unless the single expression
already evaluates to a tuple even without the parens).
Python teachers should take care to explain these points when
they introduce tuple notation in their classes!
(And even when you already know all of this, you might sometimes
forget to type this comma and sometimes might stare at the error
message and do not immediately see where the problem is located.)
In mathematics, "(1,2)" also denotes a pair (sometimes written
<1,2>). The ambiguity between the reading of "(1)" as a term
with the value of "1" and as a term the value of which is the
1-tuple containing the value "1" is observed rarely in math
because mathematics is sometimes less formal than programming
languages and 1-tuples of values can often be identified
with the value itself. So, in mathematics one rarely uses
1-tuples and very rarely needs to write them down.