On Wed, 31 Dec 2014 at 01:33PM -0600, Dan Drake wrote: > In a .sage script, I can use load('f.sage') to load all the stuff from > f.sage. But all the functions and definitions in f.sage get put into > the same namespace as the script. I'd like to get the kind of > namespace behavior you get when using the regular Python "import".
Solution: if you want it to act like "import", then use "import"... If you've written stuff in f.sage that you'd like to access with namespace support as above, the easy thing to do is to change f.sage to f.py and add "from sage.all import *" at the top. The only problem with this is that it won't work if you use any Sage-specific syntax in f.sage, such as "[1..10]" or "A\b". But you can easily fix that up by doing the preparsing yourself and pasting that into f.py: preparse('[1..10]') -> (ellipsis_range(Integer(1),Ellipsis,Integer(10))) preparse(r'A\b') -> A * BackslashOperator() * b Then do "import f" and it all works exactly the way you want. Dan -- --- Dan Drake ----- www.math.wisc.edu/~ddrake/ ------- -- 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 sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at http://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: Digital signature