Search code examples
pythonpython-3.xneuron-simulator

SyntaxError: Invalid Syntax without solution


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.


Solution

  • 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