[Tutor] FW: Comparing variables

Karthik Gurumurthy karthikg@aztec.soft.net
Tue, 8 Jan 2002 11:27:23 +0530


is it something like you have 
numStr = "1"
then you can get integer 1 by doing 
int(numStr)
but it might throw an exception depending upon what came from web page
so you might want to catch it though

try:
 num = int(numStr)
except: ValueError
 //do something here

karthik.



-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Sheree Beaudette
Sent: Tuesday, January 08, 2002 5:29 AM
To: tutor@python.org
Subject: [Tutor] FW: Comparing variables


> I need some help!!  I'm still new to Python but believe I'll need it
here.
> 
> 
> I have a form that sets the variable copyitem, a number from 1 to ...
(an
> integer)
> 
> <input type="text" name="copyitem">
> 
> Once I submit the form
> 
> I want copyitem to be compared with a sequence-number from a SQL
query,
> code as follows
> 
> <dtml-in clsqGetNotes>
> <dtml-let seqnum=sequence-number>
>   <dtml-if "seqnum == copyitem">
>      do something true
>   <dtml-else>
>      do something false
>   </dtml-if>
> </dtml-let>
> </dtml-in>
> 
> Since I've written these variables to the screen I know that they're
> equal, yet they still do the 'do something false' .
> 
> I hope it's something easy I've overlooked.  I didn't know if there
were
> type differences that I need to convert.  How do I convert these?  Do
I
> need a python script?  I'm new to Python so can you help???
> 
> Thanks in advance!


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor