Fwd: Re[4]: [Tutor] <TUTOR>My first (er...working...) script ever

Predrag Ivanovic Predrag Ivanovic <predivan@ptt.yu>
Thu Feb 27 17:39:01 2003


This is a forwarded message
From: Predrag Ivanovic <predivan@ptt.yu>
To: Gon=E7alo Rodrigues <op73418@mail.telepac.pt>
Date: Tuesday, February 25, 2003, 9:18:41 PM
Subject: [Tutor] <TUTOR>My first  (er...working...) script ever

=3D=3D=3D8<=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DOriginal message tex=
t=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Gon=E7alo Rodrigues wrote:

GR> A little better

GR> r =3D raw_input("r:")
GR> try:
GR>     newr =3D int(r)
GR> #Catch specific exception.
GR> except ValueError:
GR>     print "That is not a number"
GR> #Move print out of try block.
GR> print "whatever ", krug(newr)

Here is a code as I wrote it...
-----
r=3Draw_input("r:")
        try:
            newr=3Dint(r)
            ##Catch specific exception
        except ValueError:
            print "That'not a number."
            ##if all goes well...
        print "result is %.3d"% krug(newr)
------
When executed...
-----
Traceback (most recent call last):
  File "D:\Python22\tutorial\obim.py", line 40, in -toplevel-
    print "obim je %.3d"% krug(newr)
NameError: name 'newr' is not defined
-----
But like this...
----
r=3Draw_input("r:")
        try:
            newr=3Dint(r)
            ##Catch specific exception
        except ValueError:
            print "That'not a number."
            ##if all goes well...
        else :
            print "result is %.3d"% krug(newr)
-----
...works.


GR> With my best regards,
GR> G. Rodrigues


See you,

Pedja.

----
 "Just below my skin,I'm screaming..."
 Salva Mea,Faithless



=3D=3D=3D8<=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3DEnd of original message text=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D



--=20
Best regards,
 Predrag                            mailto:predivan@ptt.yu