statements and expressions

Erik Max Francis max at alcyone.com
Wed Jan 9 16:11:21 EST 2002


> "Alves, Carlos Alberto - Coelce" wrote:

> Why this two codes doesn't work?!
> 1st case:
>         exec("print 'Carlos' ")
> 2nd case:
>         x = exec("something")
> In former case, is it beacouse exec(..) requires an expression as
> argument and print "...." is a statement?

Yes.  Use exec for executing statements and eval for evaluating
expressions.

> And in the latter, beacouse
> statements doesn't support assignments?!

I don't know what the latter case is supposed to demonstrate here, since
"something" is not a legal Python expression or statement (well, it
would be a legal expression if there were a variable named something,
but you haven't indicated that in your example).

> Thanks in advance,

Please post in plain text, not HTML.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ Laws are silent in time of war.
\__/ Cicero
    Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
 An Esperanto reference for English speakers.



More information about the Python-list mailing list