Ask Your Question

Style guide for Sage

asked 2019-10-22 14:12:33 -0600

dsejas gravatar image

Hello, Sage Community!

I was wondering, besides the usual PEP 8, which is Python-exclusive, is there any other style guide for Sage code? I imagine there should be such thing, since Sage has its own peculiar syntax for some tasks, which are not available for Python.

Thanks in advance!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-10-22 15:32:41 -0600

Emmanuel Charpentier gravatar image

Have a look at the Sage Developer's Guide, which should answer not only your current question but also some questions you're not yet aware to have...

edit flag offensive delete link more


Hello, @emmanuel-charpentier! thank you very much. This is a helpful resource. However, I am needing something more daily-user-oriented, i.e., suggestions like "use srange instead of range if you need Sage Integers instead of Python ints", etc.

I need a guide for scientists who program on a daily basis, but they are not experts on programming. I am intending to translate that guide to Spanish for some of my colleagues who fit with this description, in order to popularize SageMath in my country (Bolivia). Otherwise, I could write such a guide by myself, but I don't want to "reinvent the wheel" in case there is one already.

dsejas gravatar imagedsejas ( 2019-10-24 11:28:25 -0600 )edit

In this case,; I can't too strongly recommend reading this book, english translation of an older french book.This is the closest equivalent to what you seek, along with a great tutorial.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-10-24 13:23:37 -0600 )edit

Thank you, @emmanuel-charpentier! Yes, I stumbled with that book a year ago. I think it could use an update. I was hoping to find something more compact, like PEP8 is. However, according to my research, there isn't such thing.

Could I ask you a question? Is it possible for me to initiate something similar to the PEP system? Something like a "Sage Enhancement Proposal" (SEP) system. There could be a SEP that could be equivalent to PEP8 for SageMath. Should I start a new question about this? How can I get help with this?

Thanks for your help!

dsejas gravatar imagedsejas ( 2019-10-24 13:30:21 -0600 )edit

Hmmmm... you want to develop a new Sage documentation, it seems...

In this case, the proper thing to do would be to request an account on Trac, open a ticket and submit a patch.

However, it might be useful first to learn about Sage and its idiosyncrasies (it has a few...), as well the Sage development process (and its developers' idiiosyncrasies, which are also a few;_). And possibly wait a few month, since the Python 2 --> 3 process presently underway will probably change some historically-rooted habits.

ISTR that the Sage Developer's guide has also some useful guidelines for would-be contributors.

You may also join sage-devel to post your question there.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2019-10-24 15:26:13 -0600 )edit

Thank you very much! I don't want to develop a new complete documentation, but a style guide. However, I can see your last comment, along with your answer, put me in the right track.

dsejas gravatar imagedsejas ( 2019-10-25 19:51:39 -0600 )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


Asked: 2019-10-22 14:12:33 -0600

Seen: 125 times

Last updated: Oct 22 '19