Quick code to get a quick answer to a relatively simple question (involving complicated structure, that i have already understood). Then i start a linux terminal, inside of it start sage by typing sage
, this gives the iron python interpreter with automatical support for classes and methods. For instance, after typing the TAB (tabulator, twice) we get the list of all methods that can be applied on the object a
,
sage: a = 2018
sage: a.abs<TAB><TAB>
a.abs a.conjugate a.dump
a.additive_order a.coprime_integers a.dumps
a.base_extend a.crt a.euclidean_degree
a.base_ring a.dat a.exact_log
a.binary a.degree a.exp
And there is a direct access to "kernel" information on the used objects:
sage: a.__class__
<type 'sage.rings.integer.Integer'>
Note that a
is already a complicated object, not a dummy python integer. To get its divisors, we can type a.di
, then the TAB(s), the list of the methods is
sage: a.di<TAB><TAB>
a.digits a.divides
a.dist a.divisors
a.divide_knowing_divisible_by
we type three more letters and then TAB again, finally the ()
. And here we have them:
sage: a.divisors()
[1, 2, 1009, 2018]
Here, it is very useful to see the names of the methods, a potential student learning - say - something about number fields, could type K.<u> = QuadraticField( 2019 )
, then K.<TAB>
and see all names of methods related / applicable for this kind of instance. This is already a lot of comfort! Note also that typing
a.divisors?
gives a description of the method, and also examples to get started. Moreover, a.divisors??
gives the code, and many sage users will never switch to Mathematica for this one reason.
Many features of iron python work, e.g. Control+A to get to the beginning of the line, Control+E for its end, Control+R to reverse search, e.g.
sage: a.divisors()
I-search backward: a.
(here i typed Control+R, then a.
, the last command i had with a.
appears, enter gets it.) Also, %cpaste
allows to paste into the interpreter bigger code chunks. (Shift+Insert inserts them. Enter would then further evaluate the lines.)
I do not know of any such work.
Have you tried to run Sage in the ipython notebook (now called Jupyter notebook):
Regarding keyboard friendship, it has automatic parenthesis completion and colored syntax.