Newbie asks(2): How to do this line of C in Py?

Lee Morgan python at lee-morgan.net
Tue Jul 10 20:34:23 EDT 2001


"Steve S.L. Wong" <sailwong at alumni.cuhk.edu.hk> writes:

> if (sscanf(command, "%d", &num) != 1 )  {
> }

One method could be

try:
 num = int( command )
except:
 pass # or perhaps num = 0
else:
 # contents of if statement 

> 
> 

-- 
Lee Morgan



More information about the Python-list mailing list