| Deutsch English Français Italiano |
|
<t6o67e$1fmu$1@gioia.aioe.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.mixmin.net!aioe.org!VcEiJc7UeGujhCV1GKeWQA.user.46.165.242.91.POSTED!not-for-mail
From: Dominique <zzz@aol.com.invalid>
Newsgroups: fr.comp.lang.python
Subject: =?UTF-8?Q?Re=3a_Comportement_=c3=a9trange_avec_IN_et_OR=2e=2e=2e?=
Date: Thu, 26 May 2022 17:26:38 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t6o67e$1fmu$1@gioia.aioe.org>
References: <t6ndp3$1igp$1@gioia.aioe.org>
<87ilpsy78b.fsf@universite-de-strasbourg.fr.invalid>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="48862"; posting-host="VcEiJc7UeGujhCV1GKeWQA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: fr
Bytes: 1858
Lines: 43
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.