gerhard wrote: > What I am after is to interact with sage from yet another language. > To do so, I need to start python from my own code. > Interestingly, when I invoke the python interpreter, > I do have access to all of the sage functionality, > as well as commands added by my code, e.g., > sage: foo > <module 'foo' (built-in)> > > sage: foo.invoke_test( float(3.), int(5) ) > 243 > > Invoking the notebook from the python prompt also works: > I can carry out computations from the notebook as before, > but I no longer have access to the added commands: > sage: foo > NameError: name 'foo' is not defined > > Shutting down the notebook returns me to the > command line interpreter and everything works as before. > > At a guess, I interact with a vanilla python process from the > notebook, > so I am missing some mods I have to do to some code somewhere?
The sage process you are interacting with in the notebook is separate from the sage process that is actually running the notebook. The sage process running the notebook creates a child sage process that actually handles the things that you do in the notebook. So if you want to define functions that you can access from the sage notebook, you will need to either define them in the notebook (or load them from a file in the notebook) or make them automatically added to sage at startup (for example, from an init.sage, I think). Jason --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---
