On Fri, Jan 10, 2020 at 3:21 PM kcrisman <kcris...@gmail.com> wrote:
>
>
>
> On Thursday, January 9, 2020 at 6:45:50 PM UTC-5, David Roe wrote:
>>
>> I had a recent discussion asking if there are any good tools for porting 
>> Sage code to Python 3.  Given the recent discussion about how long we 
>> support Python 2, it seems like one concrete step we can take to help users 
>> is to provide some documentation for doing so.
>>
>> The first step would seem to be to update our FAQ to reflect the current 
>> status (and probably the outcome of the discussion about how long we support 
>> Python 2), with a pointer to the relevant wiki pages.  But I don't see any 
>> discussion on those pages about using any of the tools for porting from 
>> Python 2 to Python 3 on .sage files.  Has anyone tried this yet?
>
>
> I've been doing a set of files by hand, and think it would be helpful for 
> there to be info on where to look for guidance on some of the more subtle 
> porting issues beyond print statements.  Two examples I hit just now:
> * Any backslash LaTeX in strings intended for consumption elsewhere in Sage 
> (via printing or MathJax, presumably) needs to be in a raw string, 
> apparently.  E.g. r"$5\equiv 2 (\text{mod }3)$" whereas before "$5\equiv 2 
> (\\text{mod }3)$" worked.

Indeed; technically the latter was always sort of incorrect, and one
should have always used raw string for latex (or double-backslashes)
since not doing so could lead to subtle bugs in your latex if, for
example, Python added a new escaped character.  Python 2 used to just
be more forgiving about this, but there has been a gradual move
towards making invalid backslash escapes an error, in order to prevent
this kind of problem in the future.  Perhaps this should be mentioned
in the Sage manual somewhere, if it isn't already (it's so vast that
maybe it is in there, but very easy to miss...)

> * I had one usage of "map" which was wrong from a Python 3 point of view in 
> the two ways not mentioned in the usual guides, e.g. see 
> https://stackoverflow.com/questions/12015521/python-3-vs-python-2-map-behavior
>
> So this would be a good service to provide, as well as what can't be handled 
> automatically with ease.  Also note that such porting tools might possibly 
> gag on some Sage non-Python syntax, e.g. f(x)=x^2 ?  Just guessing there.

Yep, that's the main problem...  none of the existing Python 2->3
porting tools will work on Sage-specific syntax unless it's been run
through the pre-parser first :(

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAOTD34YTaA4UkcOf-Q1XD_5EVVNBbB5n-jLVcvKRLvBun5JuQw%40mail.gmail.com.

Reply via email to