On Tue, 30 Dec 2008 21:16:39 +0100, Stef Mientki <stef.mien...@gmail.com> wrote:
ibpe...@gmail.com wrote:
On Dec 30, 2:48 pm, Steve Holden <st...@holdenweb.com> wrote:

Stef Mientki wrote:

hello,
      I'm running scripts, with the execute function (Python 2.5),
and it seems that triple quoted strings are not allowed.
      Is there a workaround,
or is this a fundamental problem of the exec-function ?

If you think about it, it should be obvious that you can't surround a
string to be compiled with any of the quotes that appear inside the
string to be compiled. That's about the only limitation I am aware of.

And, by the way, exec is a *statement*, not a function!

     exec ( Init_Code, PG.P_Globals )

I've really doubt that this is a statement,
unless I don't understand what a statement is.

What do you think a statement is?  According to the Python grammar, exec
is this:

   exec_stmt: 'exec' expr ['in' test [',' test]]

"stmt" is short for "statement". :)  A more satisfying demonstration of the
statementness of exec is this, though:

   >>> x = exec "foo"
     File "<stdin>", line 1
       x = exec "foo"
              ^
   SyntaxError: invalid syntax
>>>
And no, putting parenthesis around the expression given to exec doesn't make
a difference:

   >>> x = exec("foo")
     File "<stdin>", line 1
       x = exec("foo")
              ^
   SyntaxError: invalid syntax
>>>
Jean-Paul
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to