0

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.

SimoneT
  • 23
  • 1
  • 3
  • 4
    You forgot `)` at the end of that `exec('d.gmax_'+para[2]+' = '+str(para[3])` – Delrius Euphoria Aug 23 '20 at 19:32
  • 1
    Adding to @CoolCloud: The first thing to do when you get a syntax error on a seemingly perfect line is to look at the line above it and count the paired delimiters (`()`, `[]`, `{}`, triple quotes, etc.); 99.9% of the time, you didn't close one of the pairs. – ShadowRanger Aug 23 '20 at 19:36
  • Thanks to both! Now is working, with others problems. But THIS is fix! Thank you =) – SimoneT Aug 23 '20 at 20:23

2 Answers2

2

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

Delrius Euphoria
  • 14,910
  • 3
  • 15
  • 46
2

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.

scanny
  • 26,423
  • 5
  • 54
  • 80