Ask Your Question
0

Errors with sage_eval

asked 2015-01-10 09:26:01 +0200

AndreWin gravatar image

Hello!

I try to use function sage_eval and It seems for me that either I found bug either I don't understand smth.

cmds = """
def somef():
    return 443
res = somef()"""
sage_eval('res', cmds = cmds)

NameError: global name '_sage_const_443' is not defined

sage_eval('res', cmds="def somef(): return 443; res=somef()")

NameError: name 'res' is not defined.

Please give me some hints how to solve this problem. Thanks in advance.

Best regards, Andrei.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-01-11 19:12:10 +0200

slelievre gravatar image

It seems that 443 is not parsed properly in your first attempt (I don't really understand why; it might be a bug).

In any case, one way around that is the following:

sage: cmds = "def somef():\n    return Integer(443r)\nres = somef()"
sage: sage_eval('res', cmds=cmds)

In your second attempt, both return 443 and res=somef() are part of the definition of somef, so that res is not defined.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-01-10 09:26:01 +0200

Seen: 370 times

Last updated: Jan 11 '15