ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 02 Dec 2016 15:46:54 -0600Use sage files as python moduleshttp://ask.sagemath.org/question/35883/use-sage-files-as-python-modules/ I've got a project where on the one hand I'd like to use the syntactic sugar the sage preparser adds. So I want my source files to be `*.sage` not `*.py` at least in my editor. On the other hand, I would like to make use of Python's module system: each sage file should have its own module scope, and names put there should not affect other modules using the same names. I'd also like for modules to reference on another via relative imports, to facilitate code sharing.
Does Sage offer any help for this kind of use case? Any documentation somewhere?
I guess I could manually run the preparser, then rename all the files since `Foo.sage.py` can't contain a module `Foo.sage` as dots are not valid parts of a module name there. But perhaps there is something more clever. Some hook to the import system, so it can handle these `*.sage.py` files or automatically crate them via preparsing if needed. Or some way to select a different extension for the `sage -preparse` output. Or some way to have `sage.repl.load.load` do whole-file preparsing, adding relevant imports in particular. Something along these lines.MvGFri, 02 Dec 2016 15:46:54 -0600http://ask.sagemath.org/question/35883/