On 2013-11-06, Nils Bruin <[email protected]> wrote: > On Wednesday, November 6, 2013 1:56:12 AM UTC-8, Tobias Weich wrote: >> >> Hi, >> If I load some sage script and try to debug it with trace I am unable to >> see the code which I'm debugging >> >> load('~/test.sage') >> trace('example_func()') >> >> yields only to an output like: >> >> ipdb> s >> --Call-- >> > <string>(2)example_func() >> >> ipdb> s >> > <string>(3)example_func() >> >> >> which is not very helpful. If I however attach the file everything works >> fine. As I want to use my scripts in the notebook and only debug on the >> command line I have the impression that I need "load" in my scripts. Is >> there a possibility to debug in loaded files? >> > > When python interprets "code" it compiles it into an internal format, > together with some information on where to find the source (i.e., the file > the code was obtained from). When you enter code interactively there isn't > a file that can be referred to, so it's registered as coming from > "<string>". You don't get source from there. > > Sage code isn't python, so there is a translation step involved in loading > `test.sage`. As far as python is concerned, it is getting code from an > ephemeral source, just as when code is entered interactively. So the source > that python used to compile the code isn't accessible any more. > > If you do load(sage.misc.preparser.preparse_file_named('test.sage')) an > intermediate file gets produced explicitly, so python known where to look > for the source (which will be a little processed compared to what is in > your sage file. You may have to clean up the temporary file yourself > afterwards. wow, this must be in the docs! >
-- 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. For more options, visit https://groups.google.com/groups/opt_out.
