Re: Avoiding "invalid literal for int()" exception

2006-12-12 Thread Fredrik Lundh
Gabriel Genellina wrote: >>> elif uniList[0].isdigit(): >> >> The last does not work. Not only that it accepts numbers greater than 9 >> because it checks if the whole string consists of digits, it also accepts >> u'²₂' and other unicode digits. > > Oh, I didn't know that last part! Thanks. > I

Re: Avoiding "invalid literal for int()" exception

2006-12-12 Thread Gabriel Genellina
Marc 'BlackJack' Rintsch ha escrito: > In <[EMAIL PROTECTED]>, Gabriel > Genellina wrote: > > > elif uniList[0].isdigit(): > > The last does not work. Not only that it accepts numbers greater than 9 > because it checks if the whole string consists of digits, it also accepts > u'²₂' and other unic

Re: Avoiding "invalid literal for int()" exception

2006-12-12 Thread Peter Otten
Marc 'BlackJack' Rintsch wrote: > In <[EMAIL PROTECTED]>, Gabriel > Genellina wrote: > >> At Monday 11/12/2006 07:22, [EMAIL PROTECTED] wrote: >> >>>elif int(uniList[0]) in range(0,10): >> >> Either of these will work to avoid an unneeded conversion: >> >> elif uniList[0] in "0123456789": >>

Re: Avoiding "invalid literal for int()" exception

2006-12-11 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Gabriel Genellina wrote: > At Monday 11/12/2006 07:22, [EMAIL PROTECTED] 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 u

Re: Avoiding "invalid literal for int()" exception

2006-12-11 Thread Gabriel Genellina
At Monday 11/12/2006 07:22, [EMAIL PROTECTED] 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 __

Re: Avoiding "invalid literal for int()" exception

2006-12-11 Thread aine_canby
John Machin skrev: > [EMAIL PROTECTED] wrote: > > >>> v = raw_input("Enter: ") > > Enter: kjjkj > > >>> int(v) > > Traceback (most recent call last): > > File "", line 1, in > > ValueError: invalid literal for int() with base 10: 'kjjkj' > > > > In my program I need to be able to enter char st

Re: Avoiding "invalid literal for int()" exception

2006-12-11 Thread John Machin
[EMAIL PROTECTED] wrote: > >>> v = raw_input("Enter: ") > Enter: kjjkj > >>> int(v) > Traceback (most recent call last): > File "", line 1, in > ValueError: invalid literal for int() with base 10: 'kjjkj' > > In my program I need to be able to enter char strings or int strings on > the command

Re: Avoiding "invalid literal for int()" exception

2006-12-11 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, aine_canby wrote: > elif uniList[0].lower() in ("p","pass"): > break > elif int(uniList[0]) in range(0,10): Replace this line with: elif uniList[0].isdigit() and 0 <= int(uniList[0]) < 10: > verb.SetImportance(int(uniList[0])) > break > else: >

Avoiding "invalid literal for int()" exception

2006-12-11 Thread aine_canby
>>> v = raw_input("Enter: ") Enter: kjjkj >>> int(v) Traceback (most recent call last): File "", line 1, in ValueError: invalid literal for int() with base 10: 'kjjkj' In my program I need to be able to enter char strings or int strings on the command line. Then I use an if-elif structure to es