Hi Martin, Hi Nathan,
Thank you both for your replies.
The solution was effectively using exec. The difference is not very
straightforward but I think I got it!
Btw, I am using this to save list in a layer custom property, and the
way I found is playing with repr and eval exec.
Thanks again! You save me a lot of time, I was not looking in the right
direction!
Denis
On 02/09/2012 10:41 AM, Martin Dobias wrote:
On Thu, Feb 9, 2012 at 10:33 AM, Denis Rouzaud<[email protected]> wrote:
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'")
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.
eval("1+2")
3
exec "x=1"
x
1
Also note that exec is a statement (no parentheses) while eval is a
builtin function.
Martin
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer