Python Forum
Misterious invalid syntax
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Misterious invalid syntax
#1
Hello.

I need help with one of my scripts. It worked yesterday, but today (with no chenge at all!) it suddenly stopped working. The mistake is "invalid syntax" at line 20.

The code is:
from scipy import integrate
import numpy as np

T0=293
C=120
c=300
R=0.02
gam=1.7
lam=1.5*10**(-6)
p0=60
ro=1.127
w=2*np.pi*30
X=0

tmin=0
tmax=2*np.pi/w

etav = lambda x: lam*((T0+T0*(gam-1)*((p0/(ro*c)*np.cos((-w*x))/c))**(3/2))/(T0+T0*(gam-1)*((p0/(ro*c)*np.cos((-w*x))/c)+C)*p0/(ro*c)*np.cos((-w*x)

setav=integrate.quad(etav,tmin,tmax)

fl=lambda x: 6*np.pi*R*lam*((T0+T0*(gam-1)*((p0/(ro*c)*np.cos((2*np.pi/lam)*X-w*x))/c))**(3/2))/(T0+T0*(gam-1)*((p0/(ro*c)*np.cos((2*np.pi/lam)*X-w*x))/c)+C)*p0/(ro*c)*np.cos((2*np.pi/lam)*X-w*x)

Fl= integ.quad(fl,tmin,tmax)
#F=6*np.pi*R*setav

print(setav)
print(Fl)
Thanks for answers.
Reply
#2
you should break your calculations into smaller pieces, it's too hard to read as posted.
Or at least span lines.
Reply
#3
You have 19 open brackets and 16 close brackets in the previous line.

As @Larz60+ sais break it into smaller steps. Errors in such an expression are inescapable.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
(Mar-30-2018, 03:41 PM)wavic Wrote: You have 19 open brackets and 16 close brackets in the previous line

Thanks, that worked! :) - I was confused by the localization of the mistake.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to find what is causing the unboundlocalerror 'crumb' and invalid syntax error? JonathanBanks 1 2,261 Jul-28-2020, 11:46 AM
Last Post: Yoriz
  SyntaxError: invalid syntax Truman 3 2,908 Mar-10-2020, 03:16 PM
Last Post: Truman
  list comprehension invalid syntax mcgrim 1 4,598 Jun-12-2019, 08:28 PM
Last Post: Yoriz
  %matplotlib inline , invalid syntax yamoon 1 13,011 Jul-12-2018, 07:22 AM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020