Emil wrote:
Thanks Leif. inspect.getfile() doesn't seem to do what I want.
The situation is that I have a number of scripts, s1.sage, s2.sage, etc,
and I'd like them to be able to write to a '.js' file with the same name
as their filenames, e.g. s3.sage would write to s3.js, etc. I thought I
might be able to do something like open(__name__ + ".js", w")...
Ah ok, this no longer works with preparsed (i.e. .sage) files, only in
debug mode, since otherwise they get preparsed in memory.
As a work-around, you could "manually" preparse them, and instead load
the generated .py files.
(I.e., for example do 'sage --preparse s?.sage' before starting Sage /
running the scripts that load them.)
Or just explicitly define the filenames in the scripts to load, e.g. by
$ for f in s?.sage; do echo "output_filename='`basename $f`.js'" >>$f; done
(assuming you don't load more than one of them into the same Sage
session, or write the files before loading the next script).
Or similarly use 'sed' to replace some other patterns by the desired
filenames in the scripts.
[I think there was some related thread recently on sage-devel, since
tracebacks don't always contain the proper filename either IIRC.]
-leif
--
() The ASCII Ribbon Campaign
/\ Help Cure HTML E-Mail
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.