[Fwd: Re: [Tutor] Syntax error]

Bob Gailer ramrom@earthling.net
Tue Feb 18 22:23:03 2003


--=======68457673=======
Content-Type: text/plain; x-avg-checked=avg-ok-2CCF425C; charset=iso-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

These 2 lines have unbalanced parentheses:
efbh =3D ((uppvarm/graddar*24) * (20-(dut))
gradkorr =3D ((gradnorm/graddar)*uppvarm
Fix them and things should be OK.

For future reference, its important to distinguish between compile errors=20
and execution errors. These are compile errors; they appeared before any=20
input was requested or output generated.

The thing that makes it hard to find this kind of problem is that there's=20
an extra left parentheses which causes Python to expect more lines that=20
will eventually provide the closing parenthesis. When the following line=20
fails to do that, and the combination of the 2 lines is in error, it=20
reports the problem as having to do with the 2nd line. Notice what happens=
=20
when you enter the 2 lines interactively:
 >>> gradkorr =3D ((gradnorm/graddar)*uppvarm   ## extra left (
... print stringJ, gradkorr                                 ## ... tells=20
you its waiting for more
   File "<stdin>", line 2
     print stringJ, gradkorr                                 ## print=20
following uppvarm is incorrect.
         ^
SyntaxError: invalid syntax

So if the line reported looks OK, go back in the file and look at the=20
previous line(s). An IDE such as PythonWin is helpful here because it=20
highlights pairs of () [] {} "" '' etc. and makes it easy to spot extra=20
delimiters.

At 01:00 AM 2/19/2003 +0100, Roland Casselbrant wrote:

>HEre is the complete code:
>
>hhe =3D 5000.0
>vvu =3D 5000.0
>stringA =3D 'Nettoenergibehovet: '
>stringB =3D 'Nettoenergibehov minus vattenuppvarmning: '
>stringC =3D 'Kompenserat for elpannans verkningsgrad: '
>stringD =3D 'Effektbehovet vid dimensionerande temperatur: '
>stringE =3D 'Till detta tillkommer arsmedeleffekt f=F6r=
 varmvattenuppvarmning: '
>stringF =3D 'Dimensionerande effektbehov for flerbostadshuset i exemplet=20
>blir da: '
>stringZ =3D '                   '
>stringG =3D '   Effektbehov for eluppvarmt hus  '
>stringH =3D 'Program skrivet av Roland Casselbrant'
>stringI =3D '*************************************'
>stringJ =3D 'Efter gradkorrigering av varmebehovet har vi: '
>stringK =3D 'Ett normalar blir elanvandningen f=F6r smahuset i exemplet=
 alltsa: '
>
>
>print stringZ
>print stringZ
>print stringG
>print stringH
>print stringI
>print stringZ
>
>totel =3D input("Total elaanvandning per ar: [kWh] ")
>pannverk =3D input("Elpannans armedelverkningsgrad: [%] ")
>totyta =3D input("Total uppvarmd bostadsyta: [m2] ")
>byggar =3D input("Byggar: ")
>graddar =3D input("Graddagar aktuellt ar: ")
>gradnorm =3D input("Graddagar normalar: ")
>dut =3D input ("Dimensionerande utetemperatur: [grader Celsius] ")
>
># F=F6rst m=E5ste man r=E4kna bort den del av f=F6rbrukningen
># som inte =E4r klimatberoende
># d.v.s. hush=E5llsel och varmvattenuppv=E4rmning.
># Vi r=E4knar h=E4r med 5000 kWh hush=E5llsel och 5000 kWh
># f=F6r varmvattenuppv=E4rmning.
># Uppv=E4rmningsbehovet blir d=E5:
>
>print stringA, totel
>print stringZ
>
>nettoel =3D totel-vvu-hhe
>
>print stringB, nettoel
>print stringZ
>
># Nu =E4r inte hela denna energim=E4ngd "nyttig" utan vi m=E5ste kompensera
># f=F6r elpannans verkningsgrad. S=E5ledes =E4r nettoenergibehovet
># f=F6r uppv=E4rmning:
>
>panna =3D pannverk/100.0
>uppvarm =3D nettoel*panna
>
>print stringC, uppvarm
>print stringZ
>
># Effektbehovet vid dimensionerande temperatur l=F6ser vi ut
># fr=E5n ekvationen:
>
>efbh =3D ((uppvarm/graddar*24) * (20-(dut))
>
>print stringD, efbh
>print stringZ
>
># Till detta tillkommer =E5rsmedeleffekt f=F6r varmvattenuppv=E4rmning.
>
>mdff =3D (vvu/8760)
>
>print stringE, mdff
>print stringZ
>
># Dimensionerande effektbehov f=F6r flerbostadshuset i exemplet blir d=E5:
>
>deff =3D efbh+mdff
>
>print stringF, deff
>print stringZ
>
># Graddagskorrigering av v=E4rmebehovet g=E5r till s=E5 att man tar
># kvoten av graddagarna
># f=F6r normal=E5r och graddagarna f=F6r aktuell period och multiplicerar
># med det
># klimatberoende nettoenergibehovet f=F6r uppv=E4rmning enligt f=F6ljande:
>
>gradkorr =3D ((gradnorm/graddar)*uppvarm
>
>print stringJ, gradkorr
>print stringZ
>
># Ett normal=E5r blir elanv=E4ndningen f=F6r sm=E5huset i exemplet allts=E5=
:
>
>totalel =3D ((gradkorr/panna)+(vvu+hhe))
>
>print stringK, totalel
>print stringZ
>
>
>EOF/roland.casselbrant@bonetmail.com
>
>
>
>-------- Original Message --------
>Subject: Re: [Tutor] Syntax error
>Date: Tue, 18 Feb 2003 16:06:45 -0700
>From: Bob Gailer <ramrom@earthling.net>
>To: roland.casselbrant@bonetmail.com, tutor@python.org
>
>At 10:48 PM 2/18/2003 +0100, Roland Casselbrant wrote:
> >The following lines is getting Syntax errors and I can=B4t understand=
 why?
>
>Please copy the session and any associated program to the body of an e-mail
>so we can see exactly the sequence of operations and the error messages.
>
>Bob Gailer
>mailto:ramrom@earthling.net
>303 442 2625
>
>
>--
>Roland Casselbrant
>
>
>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>         Seen it all, done it all, can't remember most of it
>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
>WWW:    www.casselbrant.net
>E-mail: roland.casselbrant@bonetmail.com
>Mobile  phone: +0046-(0)70-4785052
>
>
>-----BEGIN GEEK CODE BLOCK-----
>version: 3.12
>GCM/CC/IT/O d-(++) s+:+ a C++++ UL+ P+ L+ E- W+++ N++ o K? w++++
>O++ M- V+ PS+ PE++ Y+ PGP t--- 5-- X- R* tv++(+) b++ DI+ D G e*
>h---- r+++ y++++(+++++)>$
>------END GEEK CODE BLOCK------
>
>
>
>E-mail: roland.casselbrant@bonetmail.com              ?
>WWW:    www.casselbrant.net                          ,=3D.
>                                                     (o o)
>------------------------------------------------ooO--(_)--Ooo--------
>
>
>           I only eat food delivered by www.kummingarden.com
>
>                                                  .oooO
>                                                  (   )   Oooo.
>--------------------------------------------------\ (----(   )-------
>This signature file may not be reproduced,         \_)    ) /
>in whole or in part, by any means,                       (_/
>including but not limited to:
>Mechanical reprints, electronic storage or scanning, theatrical release,
>musical ballads, word of mouth, sign language, braille, pantomime,
>hetero- or asexual reproduction, genetic engineering, or inclusion in
>digital media.
>                             In the process of producing this e-mail
>                               signature file, no apes, ratts, chaffinch,
>                    '''        bullys, snouts, CEOs, CIOs or cute pets
>                   (0 0)                   came to any harm or danger.
>        +-----oOO----(_)----------+
>        | Casselbrant Web Factory |
>        |     "The Power-Tool     |        The only thing regarded worse
>        |       of Internet"      |        than spam mail is excessive
>        +------------------oOO----+        signature files like this one.
>                  |__|__|
>                   || ||                   Made with love and a editor.
>                  ooO Ooo
>
>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>             Gravity isn't MY fault--I voted for velcro!
>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
>
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.454 / Virus Database: 253 - Release Date: 2/10/2003
>
>
>
>---
>Incoming mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.454 / Virus Database: 253 - Release Date: 2/10/2003

Bob Gailer
mailto:ramrom@earthling.net
303 442 2625

--=======68457673=======
Content-Type: text/plain; charset=us-ascii; x-avg=cert; x-avg-checked=avg-ok-2CCF425C
Content-Disposition: inline


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.454 / Virus Database: 253 - Release Date: 2/10/2003

--=======68457673=======--