Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

About hiding source code - you can do the following:

  1. Write your code in a .sage and run sage -python a.sage to generate the .py file, OR directly write a python .py file. Let us say the file name is a.py.
  2. Run sage -ipython and then compile the python file to a .pyc file by doing the following

    In [1]: import py_compile

    In [2]: py_compile.compile('a.py')

  3. Now you have a a.pyc file in the current directory. In your worksheet, use Data -> Upload or create file to upload this a.pyc file.

  4. Next, in a cell add the DATA to your PYTHONPATH like this

    os.environ['PYTHONPATH'] += (':' + DATA)

  5. Finally, import your functions and other stuff from a.pyc by running

    from a import *

It should not be possible to see the source code of your functions. I don't know if there is any way of getting the source code out of a pyc file. If it is possible, then a really curious student will simply download this file and decompile it.

About 3D interactive animations - I don't think it is possible. You can have some interactivity by using the @interact decorator, but it is in no way a smooth or very responsive way of implementing what you want.