Language Python does not work

19 views
Skip to first unread message

ekwa...@gmail.com

unread,
Sep 14, 2022, 5:39:59 AM9/14/22
to sage-cell
With Python chosen as "Language", there is no output for any input.

Is it broken? Or am I missing something? 

Andrey Novoseltsev

unread,
Sep 16, 2022, 4:23:55 PM9/16/22
to sage-cell
There is no automatic output because running your code in Python translates into executing

exec(code)

in Sage, which does not return anything and so there is nothing to display. Although if you include print(...) inside of your code, you will get the output. Other languages are executed as

print(language.eval("code"))

so typically you see the last value automatically.

As far as I can tell, this is not a new behaviour, so nothing is "broken". Either nobody has used this language, or they were happy with how it works, or they suffered silently. It does seem inconsistent with other languages, but at this point I am not eager to change anything for historical reasons. It is also not immediately clear to me what the replacement code must be.

Thank you for pointing this out!
Andrey

ekwa...@gmail.com

unread,
Sep 16, 2022, 5:32:55 PM9/16/22
to sage-cell
On Saturday, September 17, 2022 at 5:23:55 AM UTC+9 novo...@gmail.com wrote:
Either nobody has used this language, or they were happy with how it works, or they suffered silently. It does seem inconsistent with other languages, but at this point I am not eager to change anything for historical reasons.

It is a bug. Why not fix it?
 
It is also not immediately clear to me what the replacement code must be.

print(eval("code")) 

 

ekwa...@gmail.com

unread,
Sep 16, 2022, 5:41:32 PM9/16/22
to sage-cell
On Saturday, September 17, 2022 at 6:32:55 AM UTC+9 ekwa...@gmail.com wrote:
It is also not immediately clear to me what the replacement code must be.

print(eval("code")) 

Not sure if this works...


 

ekwa...@gmail.com

unread,
Sep 16, 2022, 6:01:10 PM9/16/22
to sage-cell
A proper fix would be to make print(python.eval("code")) work in sage.

There is no easy fix in sagecell right now. 

Okay. Thank you!


Reply all
Reply to author
Forward
0 new messages