Re: Python told me a Joke

Liste des GroupesRevenir à cl python 
Sujet : Re: Python told me a Joke
De : janburse (at) *nospam* fastmail.fm (Mild Shock)
Groupes : comp.lang.python
Date : 02. Sep 2024, 09:05:30
Autres entêtes
Message-ID : <vb3rka$21vqv$1@solani.org>
References : 1
User-Agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 SeaMonkey/2.53.18.2
You can try:
 >>> 1,2 == 2,2
(1, True, 2)
Its the same as:
 >>> 1, (2 == 2), 2
(1, True, 2)
Hope this helps!
Alan Bawden schrieb:
     Python 3.10.5 (v3.10.5:f37715, Jul 10 2022, 00:26:17) [GCC 4.9.2] on linux
     Type "help", "copyright", "credits" or "license" for more information.
     >>> x,_,z = [1,2,3]
 Works as expected.
 Now I didn't expect the following to work (but Python sometimes
surprises me!), so I tried:
       >>> x,2,z = [1,2,3]
       File "<stdin>", line 1
         x,2,z = [1,2,3]
             ^^^^^^^^^^^
     SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
 Yeah, that makes sense, no surprises today...  Except "maybe you meant
'=='..." caught my attention.  _Could_ that be what someone would want
in this situation I wondered?  So I tried:
      >>> x,2,z == [1,2,3]
     (1, 2, False)
 Now that made me laugh.
 - Alan
 [ Some people reading this will be tempted to explain what's really
   going on here -- it's not hard to understand.  But please remember that
   a joke is never funny if you have to explain it. ]
 

Date Sujet#  Auteur
2 Sep 24 * Python told me a Joke3Alan Bawden
2 Sep 24 +- Re: Python told me a Joke1Mild Shock
3 Sep 24 `- Re: Python told me a Joke (Posting On Python-List Prohibited)1Lawrence D'Oliveiro

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal