# load contents of a .txt file into a Sage worksheet

I am on a Mac with OS 10.11.6, and I'm learning the notebook interface for Sage 7.2. As a start, in a Sage worksheet I created a .txt file containing the string "[1, 2, 3]" and saved it. I can open the text file directly and verify its contents just by clicking on it, but I can't yet do this in Sage. I'd like to be able to open it and convert the string to a usable Sage object. I'd appreciate explicit instructions, assuming nothing at all about my Sage background. Thank you.

Edit: In Mathematica for example I can write 'stream=OpenWrite["filename"];Write[stream,{89}];Close[stream]', execute; Mathematica says "filename". Then suppose I close Mathematica, shut off my Mac, re-open my Mac and Mathematica again, open a fresh notebook, write "stream2=OpenRead["filename"];list=ReadList[stream2];Close[stream2];list". If I do all that, Mathematica will say "{{89}}}". This is usable. If I next do "list[[1,1]]+ 1", Mathematica will say "90". I want to do the same kind of thing in Sage.

Remark: if in my particular environment I try the example in the Sage documentation in the section 'Saving and Loading Individual Objects': "A = MatrixSpace(QQ,3)(range (9))^2;A" --Sage returns the matrix and "save(A, 'A')" returns a hot link to A.sobj . If I then quit Sage and restart it, the next suggested command, "A = load('A')" evokes an error message:Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_3.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\n" + _support_.preparse_worksheet_cell(base64.b64decode("QSA9IGxvYWQoJ0EnKQ=="),globals())+"\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>

File "/private/var/folders/7n/t9k4hfyn44s2qp7wxt479kn80000gn/T/tmpMnKw2r/___code___.py", line 2, in <module> exec compile(u"A = load('A')" + '\n', '', 'single') File "", line 1, in <module>

File "sage/structure/sage_object.pyx", line 1032, in sage.structure.sage_object.load (build/cythonized/sage/structure/sage_object.c:11594) IOError: [Errno 2] No such file or directory: 'A.sobj' Remark 2: I replicated this error on a Mac laptop using Sage 6.8 and OS 10.10.2.

See also http://stackoverflow.com/questions/39...