Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Sage on Windows is still running in a UNIX-like environment called Cygwin. In Cygwin, you'll find that Windows style paths generally do work in Python. For example you'll find that the following works:

sage: print(open('C:\\Users\\Javier\\Desktop\\current\\height1\\height1.sage').read())

(Note the double-backslashes--the \ in Python is an escape character, so when you use Windows paths in Python you have to escape the backslash itself. Frequently Python will be forgiving of this if you have some \<C> that is not a known escape sequence. But if you have something like \n then it will still treat that as a newline (for example, since \n is a known escape sequence in Python).

However, it looks like there's a bug in os.path.abspath on Cygwin, where it does not recognize Windows-style paths as absolute paths. I'm glad you brought this up, since I believe that should actually be fixed in Python. This is because Python on Cygwin doesn't actually inherently understand Windows paths--the translation to UNIX-style paths happens transparently in the Cygwin layer. Oops!

You're better off using UNIX-style paths with forward-slashes. Check out what

sage: os.path.abspath('Desktop/current/height1/height1.sage')

returns. I think you'll be pleasantly surprised.