Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > fr.comp.lang.python > #3350
| Path | csiph.com!aioe.org!news.gegeweb.eu!gegeweb.org!news.ortolo.eu!news.izac.org!reader |
|---|---|
| From | Benoit Izac <use.reply.to@INVALID.ADDRESS> |
| Newsgroups | fr.comp.lang.python |
| Subject | Re: Evaluation de chaine |
| Date | Sat, 13 Jun 2020 13:24:14 +0200 |
| Message-ID | <877dwbb44h.fsf@izac.org> (permalink) |
| References | <5ee48d9e$0$24264$426a74cc@news.free.fr> |
| Reply-To | benoit.izac@free.fr |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | keg.izac.org; logging-data="32037"; mail-complaints-to="usenet@izac.org" |
| Xref | csiph.com fr.comp.lang.python:3350 |
Show key headers only | View raw
Bonjour,
Le 13/06/2020 à 10:26, george <george@invalid.invalid> a écrit dans le
message <5ee48d9e$0$24264$426a74cc@news.free.fr> :
> Si je stocke dans a la chaine "x=3" (en faisant a="x=3") et qu'ensuite
> je fais eval(a) afin de faire référencer l'entier 3 par x, j'obtiens
> une erreur de syntaxe. Comment faire pour contourner ce problème ?
« x=3 » est une instruction, pas une expression. Il faut utiliser exec().
eval() évalue une expression, par exemple « eval('4+2+1') » renvoie
« 7 ».
--
Benoit Izac
Back to fr.comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar
Evaluation de chaine george <george@invalid.invalid> - 2020-06-13 10:26 +0200
Re: Evaluation de chaine Benoit Izac <use.reply.to@INVALID.ADDRESS> - 2020-06-13 13:24 +0200
Re: Evaluation de chaine george <george@invalid.invalid> - 2020-06-13 22:14 +0200
csiph-web