1 | initial version |
sage:
promptsage -n jupyter
sage --pip install jupyterlab
sage -n jupyterlab
sage -n sagenb
notebook()
sage -c
sage -c "print(2 + 2)"
.py
or .sage
myfile.sage
or myfile.py
sage myfile.sage
or sage myfile.py
.sage
and .py
files
.sage
files, the Sage preparser will be used.py
files, the Sage preparser will not be usedload
, runfile
, attach
, %load
, %runfile
, %attach
myfile.sage
contains def sq(a): return a*a
sage -c "load('myfile.sage'); print(sq(2))"
sage
for the Sage REPLsage_select
to select which version of Sage to use by default.sagews
).ipynb
)
rst2ipynb
, ...!
is executed as a shell command!
:
ls
, cd
, pwd
...os
and sys
read from file, all at once or line by line
with open('/path/to/file.txt', 'r') as f:
s = f.read()
with open('/path/to/file.txt', 'r') as f:
for line in f:
<do something with line>
write to file, bit by bit or line by line
with open('/path/to/file.txt', 'a') as f:
f.write('blah')
f.writelines(['haha', 'hehe', 'hihi'])
see also the csv
module for "comma-separated-values" data files