I have written a class, LRC, using the Sage Notebook which works just fine. Now I would like to put it into my sage environment without including it on each worksheet.
Before I go on I should describe my environment a bit. I am running a windows 7 machine with Virtual Box. I imported a Sage Notebook virtual machine and run it. The virtual box shares some of the drive space with the windows machine, in particular a spot called D:\unixshare
So I extracted the code from the cell to a file and placed it at D:\unixshare\forLRC\LRC.py which at least in theory available to the virtual box machine.
In a new worksheet I put this in a cell.
import sys sys.path.append('/media/sf_D_DRIVE//unixshare/forLRC') # move your python files here
import LRC
lrc = LRC()
.-.-.-.-.-.-.-.-.-.-
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_4.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("aW1wb3J0IHN5cwpzeXMucGF0aC5hcHBlbmQoJy9tZWRpYS9zZl9EX0RSSVZFLy91bml4c2hhcmUvZm9yTFJDJykgIyBtb3ZlIHlvdXIgcHl0aG9uIGZpbGVzIGhlcmUKCmltcG9ydCBMUkMKCmxyYyAgICA9IExSQygp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpMF8IdA/___code___.py", line 5, in <module> import LRC File "/media/sf_D_DRIVE//unixshare/forLRC/LRC.py", line 22, in <module> class LRC( object ): File "/media/sf_D_DRIVE//unixshare/forLRC/LRC.py", line 31, in LRC var( "myOmega" ) # sometimes used as the angular frequency
NameError: name 'var' is not defined
I did get a new file: D:\unixshare\forLRC\LRC.pyc
So I have a problem that does not let me go any farther. I am not a particularly experienced python programmer, but have programmed in various languages for some time. Some help? Thanks.