Avoiding "invalid literal for int()" exception

Gabriel Genellina gagsl-py at yahoo.com.ar
Mon Dec 11 18:30:35 EST 2006


At Monday 11/12/2006 07:22, aine_canby at yahoo.com wrote:

>elif int(uniList[0]) in range(0,10):

Either of these will work to avoid an unneeded conversion:

elif uniList[0] in "0123456789":

elif uniList[0] in string.digits:

elif uniList[0].isdigit():


-- 
Gabriel Genellina
Softlab SRL 

__________________________________________________
Correo Yahoo!
Espacio para todos tus mensajes, antivirus y antispam ¡gratis! 
¡Abrí tu cuenta ya! - http://correo.yahoo.com.ar



More information about the Python-list mailing list