ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 13 Sep 2020 01:06:08 +0200Convert sage code from v8.1 to work in v9.1https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/ Hi all,
I have a .sage file that works with Sage v8.1, however, it does not run with Sage v9.1. It seems the issues are the same issues that occur with Python2 vs Python3 syntax i.e. print statement syntax is print 'statement' vs print('statement')
Rather than go through line by line and find each difference, is there a way to convert the file to make it run for Sage 9.0 and later?
Any assistance would be appreciated!Sat, 12 Sep 2020 04:29:51 +0200https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/Comment by slelievre for <p>Hi all, </p>
<p>I have a .sage file that works with Sage v8.1, however, it does not run with Sage v9.1. It seems the issues are the same issues that occur with Python2 vs Python3 syntax i.e. print statement syntax is print 'statement' vs print('statement')</p>
<p>Rather than go through line by line and find each difference, is there a way to convert the file to make it run for Sage 9.0 and later?</p>
<p>Any assistance would be appreciated!</p>
https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53418#post-id-53418So far I've always ported code by hand but if your .sage file is public
or if you email it to me I can try some of the tools on it.Sat, 12 Sep 2020 12:24:24 +0200https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53418#post-id-53418Comment by FrédéricC for <p>Hi all, </p>
<p>I have a .sage file that works with Sage v8.1, however, it does not run with Sage v9.1. It seems the issues are the same issues that occur with Python2 vs Python3 syntax i.e. print statement syntax is print 'statement' vs print('statement')</p>
<p>Rather than go through line by line and find each difference, is there a way to convert the file to make it run for Sage 9.0 and later?</p>
<p>Any assistance would be appreciated!</p>
https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53413#post-id-53413Some useful tools are flycheck, pyflakes, flake8, pycodestyle : they allow to find the places needing care.
See also https://wiki.sagemath.org/Python3-Switch and its sub-pagesSat, 12 Sep 2020 08:07:14 +0200https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53413#post-id-53413Comment by FrédéricC for <p>Hi all, </p>
<p>I have a .sage file that works with Sage v8.1, however, it does not run with Sage v9.1. It seems the issues are the same issues that occur with Python2 vs Python3 syntax i.e. print statement syntax is print 'statement' vs print('statement')</p>
<p>Rather than go through line by line and find each difference, is there a way to convert the file to make it run for Sage 9.0 and later?</p>
<p>Any assistance would be appreciated!</p>
https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53414#post-id-53414And there is no fully automatic way.Sat, 12 Sep 2020 08:08:58 +0200https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53414#post-id-53414Comment by FrédéricC for <p>Hi all, </p>
<p>I have a .sage file that works with Sage v8.1, however, it does not run with Sage v9.1. It seems the issues are the same issues that occur with Python2 vs Python3 syntax i.e. print statement syntax is print 'statement' vs print('statement')</p>
<p>Rather than go through line by line and find each difference, is there a way to convert the file to make it run for Sage 9.0 and later?</p>
<p>Any assistance would be appreciated!</p>
https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53416#post-id-53416And all these tools are for `.py` files, of course.Sat, 12 Sep 2020 09:02:11 +0200https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53416#post-id-53416Answer by John Palmieri for <p>Hi all, </p>
<p>I have a .sage file that works with Sage v8.1, however, it does not run with Sage v9.1. It seems the issues are the same issues that occur with Python2 vs Python3 syntax i.e. print statement syntax is print 'statement' vs print('statement')</p>
<p>Rather than go through line by line and find each difference, is there a way to convert the file to make it run for Sage 9.0 and later?</p>
<p>Any assistance would be appreciated!</p>
https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?answer=53423#post-id-53423There is a script `2to3` that converts Python 2 code to Python 3 code, in addition to the tools mentioned by @FrédéricC. Try running that on the file. (It is intended for .py files, but it may also work on a .sage file. Or you can do `sage --preparse file.sage` to produce `file.sage.py`, and then run `2to3` on that.)Sat, 12 Sep 2020 18:18:40 +0200https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?answer=53423#post-id-53423Comment by Bark for <p>There is a script <code>2to3</code> that converts Python 2 code to Python 3 code, in addition to the tools mentioned by <a href="/users/1557/fredericc/">@FrédéricC</a>. Try running that on the file. (It is intended for .py files, but it may also work on a .sage file. Or you can do <code>sage --preparse file.sage</code> to produce <code>file.sage.py</code>, and then run <code>2to3</code> on that.)</p>
https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53432#post-id-53432Thank you! This is precisely what I was looking for!Sun, 13 Sep 2020 01:06:08 +0200https://ask.sagemath.org/question/53412/convert-sage-code-from-v81-to-work-in-v91/?comment=53432#post-id-53432