Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

errors when read a file with symbols

I am trying to read a file with contents like:

[4/t^4, [[-3, 3, -3], [-1, 1, -3], [1, 1, -1]]]

I use the following codes:

fp1='/Users/jianrongli/Dropbox/Georgios/data/decomposition_of_Lm_tensor_Lm.txt'
with open(fp1, 'r') as fp:
    L = [sage_eval(line) for line in fp.readlines() if line.strip()]

But it has errors:

NameError: name 't' is not defined

Is there some way to fix this? Thank you very much.