<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Martin, Hi Nathan,<br>
<br>
Thank you both for your replies.<br>
<br>
The solution was effectively using exec. The difference is not very
straightforward but I think I got it!<br>
<br>
Btw, I am using this to save list in a layer custom property, and
the way I found is playing with repr and <strike>eval</strike>
exec.<br>
<br>
Thanks again! You save me a lot of time, I was not looking in the
right direction!<br>
<br>
Denis<br>
<br>
<br>
On 02/09/2012 10:41 AM, Martin Dobias wrote:
<blockquote
cite="mid:CAC2XbFe0u3-2c3odRYdJy_V6nGJG+wAdK2XXF5EnGJOkWQsFDg@mail.gmail.com"
type="cite">
<pre wrap="">On Thu, Feb 9, 2012 at 10:33 AM, Denis Rouzaud <a class="moz-txt-link-rfc2396E" href="mailto:denis.rouzaud@gmail.com"><denis.rouzaud@gmail.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi all,
I am dealing with the same problem for a while now, can someone tells me why
these commands give a syntaxerror:
eval("myvar ='3'")
</pre>
</blockquote>
<pre wrap="">
There is a difference between evaluation (eval) and execution (exec)
of some code. When evaluating you only want a result of an expression.
When executing you actually run one or more statements in the current
context.
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">eval("1+2")
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">3
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">exec "x=1"
x
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">1
Also note that exec is a statement (no parentheses) while eval is a
builtin function.
Martin
</pre>
</blockquote>
</body>
</html>