SyntaxError: Invalid Syntax without solution

112 views Asked by At

It's my first request here, I hope you'll could help me.

I try to explain this particular situation.

Files that use are bases for launch a neuronal simulation and they were for Python 2. Using an Atom's plug-in, I fixed manually any Indent errors and details.

But for this error I can't find a solution.

Traceback (most recent call last): 
    File "./protocols/01_no_channels_ais.py", line 4, in <module>
    from Purkinje import Purkinje
    File "/Users/simonet/Desktop/purkinjecell/Purkinje.py", line 202
    listgmax = []
           ^
SyntaxError: invalid syntax

From file Purkinje

self.subsets_cm = np.genfromtxt("ModelViewParmSubset_cm.txt")
for cm in self.subsets_cm:
    for d in self.ModelViewParmSubset[int(cm[0])]:
        d.cm = cm[1] * 0.77/1.64

self.dend[138].cm = 8.58298 * 0.77/1.64

self.subsets_paraextra = np.genfromtxt("modelsubsetextra.txt", dtype=[('modelviewsubset','f8'),('channel','S5'),('channel2','S5'),('value','f8')])
for para in self.subsets_paraextra:
    for d in self.ModelViewParmSubset[int(para[0])]:
        d.insert(para[1])
        exec('d.gmax_'+para[2]+' = '+str(para[3])

listgmax = [] ############ PROBLEM WOULD BE HERE ##############

for d in self.ModelViewParmSubset[2]:
    d.gmax_Leak = d.gmax_Leak/2

self.dend[138].insert('Leak')
self.dend[138].gmax_Leak = 1.74451E-4 / 2

"listgmax" is a unique term in this code. I can't understand where is the problem.

If I delete it, the problem continue in the next line with the same error of Sintax.

Can you help me?

Thanks a lot for your time.

Hope I was clear.

2

There are 2 answers

0
Delrius Euphoria On BEST ANSWER

The error is simple, you forgot the closing brackets on the line above, so just say:

exec('d.gmax_'+para[2]+' = '+str(para[3]))

This should fix the errors. Keep in mind for such SyntaxError: invalid syntax the problem mostly is you missing to close brackets or something.

If any doubts or errors, do let me know

Cheers

0
scanny On

You're missing a closing parenthesis in the line prior. It should be:

exec('d.gmax_' + para[2] + ' = ' + str(para[3]))

The Python interpreter is reporting the error on the next line because that's the soonest it can tell you didn't just continue the same expression there. In general, with syntax errors, good to look above if you don't find the error exactly where reported.