Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3889
| From | Dominique <zzz@aol.com.invalid> |
|---|---|
| Newsgroups | fr.comp.lang.python |
| Subject | Re: Comportement étrange avec IN et OR... |
| Date | 2022-05-26 17:26 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <t6o67e$1fmu$1@gioia.aioe.org> (permalink) |
| References | <t6ndp3$1igp$1@gioia.aioe.org> <87ilpsy78b.fsf@universite-de-strasbourg.fr.invalid> |
Le 26/05/2022 à 11:27, Alain Ketterlin a écrit :
Merci Alain,
C'est la conclusion à laquelle je suis parvenu (mauvaise utilisation de OR)
Merci pour l'ensemble de tes précisons.
Je ne connaissais pas cette subtilité :
if 'ERROR':
print('OK')
OK
même si ERROR n'esst pas défini.
Et en poussant un peu :
if not 'ERROR':
print('Non')
else:
print('OK')
OK
>
> Bref : ce que tu veux (probablement) est
>
> '*ERROR*' in test2 or 'ERR' in test2
Oui, c'était exactement ça :-)
>
> Il faut faire deux tests "in", on ne peut pas tester deux valeurs en
> même temps avec "in" : ce qui est à gauche de "in" doit être une chaîne
> (dans ton cas). Si tu écris :
>
> ('*ERROR*' or 'ERR') in test2
>
> le "or" est calculé d'abord, et tu testes en substance « '*ERROR*' in
> test2 ».
>
> -- Alain.
Back to fr.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Comportement étrange avec IN et OR... Dominique <zzz@aol.com.invalid> - 2022-05-26 10:29 +0200
Re: Comportement étrange avec IN et OR... Alain Ketterlin <alain@universite-de-strasbourg.fr.invalid> - 2022-05-26 11:27 +0200
Re: Comportement étrange avec IN et OR... Dominique <zzz@aol.com.invalid> - 2022-05-26 17:26 +0200
Re: Comportement étrange avec IN et OR... Olivier Miakinen <om+news@miakinen.net> - 2022-05-26 17:52 +0200
Re: Comportement étrange avec IN et OR... Dominique <zzz@aol.com.invalid> - 2022-05-26 19:01 +0200
Re: Comportement étrange avec IN et OR... Dominique <zzz@aol.com.invalid> - 2022-05-26 11:36 +0200
Re: Comportement étrange avec IN et OR... Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2022-05-26 11:38 +0200
csiph-web