print and parentheses

20 views
Skip to first unread message

Ingo Dahn

unread,
Feb 13, 2020, 3:48:39 PM2/13/20
to sage-cell
Currently print "a", "b" gives an error in SageCell but works fine in CoCalc. The error message is loud and clear - writing print("a","b") instead works fine also in SageCell, so this is easy to correct.
My problem, however, is that I have used the print without parentheses quite often in many worksheets and gave some of them to others. All these are now broken and I am not sure where they all are.
Would it be possible to re-allow print "a", "b" also in SageCell, also to be in-line with CoCalc?

Andrey Novoseltsev

unread,
Feb 13, 2020, 3:52:35 PM2/13/20
to sage-cell
print behaviour has changed in Python 3 which is default since Sage 9.0. I believe that CoCalc is working for you fine because you are still using a Python 2 version. If there is a way to make it work long term (e.g. via preparser), the change has to be implemented in SageMath itself.

William Stein

unread,
Feb 13, 2020, 4:19:49 PM2/13/20
to Andrey Novoseltsev, sage-cell
Yes, this is one of the most user-pain-causing impacts of Sage
switching by default from Python2 (in sage-8.9) to Python3 (in
sage-9.0).

In CoCalc for *sage worksheets* we default to Python2 (sage-8.9) and
intend to for a while still. However, if you open a terminal and type

sage_select 9.0

then restart your project, it will switch to using the Python3 version
of Sage by default, and Sage worksheets should fully work (except of
course
you have to use print-as-a-function).

I certainly always imagined that we would have some preparser support
for print statements before making the big switch with Sage. However,
there was no momentum or anybody who wanted to implement that, so it
didn't happen. Also, that's really just the tip of the iceberg.
There are many, many other subtle little things that break going from
python2 to python3, and just dealing with print statements is nowhere
close to solving all the problems that would come up.

For what it is worth, I'm seriously considering putting some major
work in during the next month to make https://share.cocalc.com provide
more overlap with some of the problems that sagecell.sagemath.org
solves. If I do that, I'm likely going to prioritize longterm support
for sage-8.9 (python2) on an equal footing with python3, since I have
the resources do so, unlike with the sage cell server...

-- William

On Thu, Feb 13, 2020 at 12:52 PM Andrey Novoseltsev <novo...@gmail.com> wrote:
>
> print behaviour has changed in Python 3 which is default since Sage 9.0. I believe that CoCalc is working for you fine because you are still using a Python 2 version. If there is a way to make it work long term (e.g. via preparser), the change has to be implemented in SageMath itself.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cell+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/22a4ca44-fba0-4a23-8d0c-1a663d90adc9%40googlegroups.com.



--
William (http://wstein.org)

Ingo Dahn

unread,
Feb 13, 2020, 4:55:36 PM2/13/20
to sage-cell
Would it be possible to maintain under a different URL for some time a Python 2 based SageCell server? Changing a URL would be much easier than correcting SageCell scripts. 

Alternatively a kind of cookbook with receipts how to circumvent specific SageCell error messages might be helpful though not really a solution. 

I confess that I have very little knowledge of Python. I am using SageCell to solve specific problems and use the worksheets for some time, which means that, in order to debug a specific script I wrote a long time ago I have to go back to tutorials I find on the web and I tend to get lost if the examples in these tutorials aren't working anymore. 

In fact in my use case the situation is even worse because many of my SageCell scripts don't live in SageCells - I use SageCells mostly as tools for students to solve randomized math problems. To that end, the math problem generates the SageCell script or instantiates its parameters;. I don't even have a way to find out which of my problems use SageCell!
> To unsubscribe from this group and stop receiving emails from it, send an email to sage...@googlegroups.com.

Andrey Novoseltsev

unread,
Feb 13, 2020, 5:07:47 PM2/13/20
to sage-cell
One can certainly setup a server with older versions of SageMath and SageMathCell. Note, however, that Python 3 has been live for a month and a half and we didn't get that many complaints about the switch. This does not mean of course that people don't run into problems, rather I think that very few people would take advantage of changing a URL to use an older version. Besides it is not a long-term solution anyway, you'll have to switch to supported versions at some point.

William Stein

unread,
Feb 13, 2020, 5:18:34 PM2/13/20
to Andrey Novoseltsev, sage-cell
I just tried looking at

https://wiki.sagemath.org/interact

and it was difficult to find anything that was NOT broken. E.g., I
tried many of the interacts under "miscellaneous" and every single one
I tried was broken. I don't know if that is due to Python3 or other
issues though.

It's possible that a large amount of usage of sagecell is broken, but
people don't complain via email to you about the problems. Do you
log whether or not a sage cell evaluation works or produces a
traceback? If so, did the percentage of tracebacks go up dramatically
after the switch?

William

On Thu, Feb 13, 2020 at 2:07 PM Andrey Novoseltsev <novo...@gmail.com> wrote:
>
> One can certainly setup a server with older versions of SageMath and SageMathCell. Note, however, that Python 3 has been live for a month and a half and we didn't get that many complaints about the switch. This does not mean of course that people don't run into problems, rather I think that very few people would take advantage of changing a URL to use an older version. Besides it is not a long-term solution anyway, you'll have to switch to supported versions at some point.
>
> --
> You received this message because you are subscribed to the Google Groups "sage-cell" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cell+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/a3d0bca5-2d48-4754-90cd-1931265f0da0%40googlegroups.com.



--
William (http://wstein.org)

Ingo Dahn

unread,
Feb 13, 2020, 5:47:30 PM2/13/20
to sage-cell
Here is another problem:
SageCells using R not too seldom have 'NULL' in its output, apparently when some R command has no output (that was the interpretation of a colleague of mine from Erlangen University who is using SageCell with R for teaching.)

Would it perhaps be possible that SageCell falls back to a Python 2 version instead of producing Python-3-related errors?

Can you recommend a set of online tutorials and manuals where the examples have been checked for compatibility with Python 3 SageCell?

Andrey Novoseltsev

unread,
Feb 13, 2020, 6:09:39 PM2/13/20
to sage-cell
On Thursday, 13 February 2020 15:18:34 UTC-7, William Stein wrote:
I just tried looking at

https://wiki.sagemath.org/interact

and it was difficult to find anything that was NOT broken.   E.g., I
tried many of the interacts under "miscellaneous" and every single one
I tried was broken.  I don't know if that is due to Python3 or other
issues though.

It's possible that a large amount of usage of sagecell is broken, but
people don't complain via email to you about the problems.    Do you
log whether or not a sage cell evaluation works or produces a
traceback?  If so, did the percentage of tracebacks go up dramatically
after the switch?

William

There is no logging of what happens with the output and in general tracebacks are quite natural when you are writing code, but indeed they can be more frequent now. I do, however, receive emails about things not working and there was no significant change in their frequency. About a day after deployment I also got an email about other languages not working - I fixed it and it was the only "real bug" that I didn't catch in transition.

Andrey Novoseltsev

unread,
Feb 13, 2020, 6:13:53 PM2/13/20
to sage-cell
On Thursday, 13 February 2020 15:47:30 UTC-7, Ingo Dahn wrote:
Here is another problem:
SageCells using R not too seldom have 'NULL' in its output, apparently when some R command has no output (that was the interpretation of a colleague of mine from Erlangen University who is using SageCell with R for teaching.)

This has been the case for a year now:

Would it perhaps be possible that SageCell falls back to a Python 2 version instead of producing Python-3-related errors?

What do you mean? Keep using Python 2 longer and then switch at some point? What would be different at that point?
 
Can you recommend a set of online tutorials and manuals where the examples have been checked for compatibility with Python 3 SageCell?

There is nothing specific to Python 3 in SageCell - you are supposed to get the same results as when using Sage 9.0 locally or via CoCalc. If you don't - that's a bug that should be fixed.

Rob Beezer

unread,
Feb 14, 2020, 1:06:52 AM2/14/20
to sage...@googlegroups.com
The Sage Cell examples here are being tested and upgraded for Python 3 right now. I can't say exactly how far along that work is, but I believe the progress is substantial.

https://utmost.aimath.org/sage-cell-repository/

I'll note in passing that Python 3.0 was released in 2008.

Ingo Dahn

unread,
Feb 14, 2020, 2:19:01 AM2/14/20
to sage-cell
As a user of SageCell I don't care whether it runs on Python 2 or 3 but I DO care about it's BACKWARDS COMPATIBILITY. Backwards compatibility is (at least for me) a cornerstone of trust in sustainability. When I give out a worksheet for others to use it leaves my control but it takes some of my reputation with it - which breaks if the worksheet stops working for whatever reason. In fact, changing the format of the print statement broke many of my worksheets.

Ultimately, I don't care whether backwards compatibility is achieved through a pre-processor or through a fallback installation.

Having said this, I hasten to emphasise my highest appreciation for  theSageCell developers and maintainers. In my context I wouldn't have any other system to replace SageCell.

kcrisman

unread,
Feb 14, 2020, 10:38:57 AM2/14/20
to sage-cell



As a user of SageCell I don't care whether it runs on Python 2 or 3 but I DO care about it's BACKWARDS COMPATIBILITY. Backwards compatibility is (at least for me) a cornerstone of trust in sustainability.

Thus highlighting one of the soft spots of much open source development - developers, in the end, will largely work on what they feel is important, which may not be what end users feel is important.  I actually think Sage does better than most with this; the fact that the Sage notebook transition was supported as well as it was is pretty impressive.  But with the Py3 transition (now I am not specifically talking about Sage cell) the general active developer attitude has been to peel off the bandage quickly, and for better or for worse OSS has to go with the active developers.

However, if we aren't hearing from people, it doesn't mean they aren't encountering problems.  It means they will just use Desmos or Wolfram Alpha rather than Sage Cell.  (At least anecdotally, Desmos has huge "market share" among my students, interestingly.)  Committed users like myself, or ones with mechanisms to update like UTMOST, may continue, but a lot will throw up their hands in frustration.  I'm glad you agree that Sage cell is awesome enough that it is worth dealing with this particular frustration!

Andrey Novoseltsev

unread,
Feb 14, 2020, 12:21:19 PM2/14/20
to sage-cell
I understand very well how unpleasant it is to discover your code/worksheets broken. Note, however, that each new version of Sage may and usually does break something. The goal is to have deprecation warnings before a break occurs for a year or longer and that's I think is the real problem with Python 3 transition - there were no warnings that print statement will stop working or map will change the returned value from a list to an iterator. This is very unfortunate, but since nobody was going to work on it the only thing under our control was timing the unpleasant transition. For SageMathCell is was the winter break, CoCalc still has 8.9 as the default.

For situations where having no unexpected upgrades and downtime is crucial, i.e. when you are using something for exams, the only reliable solution for SageMathCell is to run your own server, which is precisely what I have done many years ago. Took me quite a while to setup, but was one of the reasons I could pick up maintenance and development when Jason Grout left. I've tried to simplify this independent setup option, but have no idea how many people are taking advantage of it. Running old versions of Sage used to be on my TODO list, but it never seemed to be a high priority for anybody else and for me updates are never unexpected anymore ;-)

Ingo Dahn

unread,
Feb 14, 2020, 1:03:29 PM2/14/20
to Andrey Novoseltsev, sage-cell
This is what I did now.
  1. I maintain a registry of the worksheets which I have made online available, tested 100% of them, found ca. 30% broken and corrected those. Remaining problems are the NULL problem for R sheets and failure to plot factorial(x). I still have to go through and eventually correct all my online scripts with embedded SageCells but I have no chance even to find those cells which are embedded in Math questions in a large question library.
  2. I issued a warning to the colleagues in my network, asking them to check SageCells before using them for teaching, informed them about the workarounds I know and asked them to report to me any other error that they may find. Will forward those.
We seriously discussed here already some time ago whether we might set up our own SageCell server, but decided that we wouldn't have the capacity to run and support it.

Am Fr., 14. Feb. 2020 um 18:21 Uhr schrieb Andrey Novoseltsev <novo...@gmail.com>:
I understand very well how unpleasant it is to discover your code/worksheets broken. Note, however, that each new version of Sage may and usually does break something. The goal is to have deprecation warnings before a break occurs for a year or longer and that's I think is the real problem with Python 3 transition - there were no warnings that print statement will stop working or map will change the returned value from a list to an iterator. This is very unfortunate, but since nobody was going to work on it the only thing under our control was timing the unpleasant transition. For SageMathCell is was the winter break, CoCalc still has 8.9 as the default.

For situations where having no unexpected upgrades and downtime is crucial, i.e. when you are using something for exams, the only reliable solution for SageMathCell is to run your own server, which is precisely what I have done many years ago. Took me quite a while to setup, but was one of the reasons I could pick up maintenance and development when Jason Grout left. I've tried to simplify this independent setup option, but have no idea how many people are taking advantage of it. Running old versions of Sage used to be on my TODO list, but it never seemed to be a high priority for anybody else and for me updates are never unexpected anymore ;-)

--
You received this message because you are subscribed to a topic in the Google Groups "sage-cell" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-cell/Kz4koL1C1nU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-cell+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cell/f1b16004-d9d3-44bf-8d67-7354bd89d572%40googlegroups.com.

Andrey Novoseltsev

unread,
Feb 17, 2020, 11:02:59 AM2/17/20
to sage-cell
On Friday, 14 February 2020 11:03:29 UTC-7, Ingo Dahn wrote:
We seriously discussed here already some time ago whether we might set up our own SageCell server, but decided that we wouldn't have the capacity to run and support it.

Any chance you can elaborate on this decision? Were hosting requirements problematic or manpower to support it? Has anyone tried following instructions on https://github.com/sagemath/sagecell/tree/master/contrib/vm ? 
Reply all
Reply to author
Forward
0 new messages