Re: Silly/crazy problem with sqlite

Liste des GroupesRevenir à cl python 
Sujet : Re: Silly/crazy problem with sqlite
De : ram (at) *nospam* zedat.fu-berlin.de (Stefan Ram)
Groupes : comp.lang.python
Date : 25. Nov 2023, 22:12:08
Autres entêtes
Organisation : Stefan Ram
Message-ID : <tuples-20231125220335@ram.dialup.fu-berlin.de>
References : 1 2 3 4
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.



Date Sujet#  Auteur
25 Nov 23 * Re: Silly/crazy problem with sqlite2Stefan Ram
25 Nov 23 `- Re: Silly/crazy problem with sqlite1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal