Ask Your Question
2

Importing user SAGE files "pythonically"

asked 2017-12-09 16:15:19 +0100

Vincent Russo gravatar image

Hello,

I'm wondering if there's a more "pythonic" way in which to import user-written SAGE modules.

For instance, I'm able to load in a SAGE file I've written using the load keyword.

load(path_to_sage_file)

That's all well and good, however, as I start to import more and more user SAGE files, where certain functions are coming from becomes less clear. It would be ideal to do something like

from name_of_sage_file import name_of_sage_function

However, this doesn't seem to work. Is there a more "pythonic" way in which to go about doing this? Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-12-09 19:04:55 +0100

slelievre gravatar image

See the related Ask Sage question: https://ask.sagemath.org/question/33954/can-i-create-a-sage-file-and-import-it-as-a-python-module/.

See also this template for packaging Sage code as a Python module: https://github.com/sagemath/sage_sample/.

See also these slides by Marc Masdeu about packaging Sage code as a Python module and distributing it: https://www.slideshare.net/mmasdeu/distributing-sage-python-code-the-right-way.

edit flag offensive delete link more

Comments

Why-oh-why is this not more explicitly stated in the documentation. Thank you, good sir.

Vincent Russo gravatar imageVincent Russo ( 2017-12-10 01:09:37 +0100 )edit

Do you see a place in the documentation where this would fit well? Please suggest a change.

One way the documentation gets better is when this "why-oh-why" feeling makes users take action!

slelievre gravatar imageslelievre ( 2017-12-11 23:28:16 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-12-09 16:15:19 +0100

Seen: 764 times

Last updated: Dec 09 '17