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":
>> 
>> elif uniList[0] in string.digits:
>> 
>> 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.

By the way, if you require an implicit 0 <= int(s) < 10 check, none of the
above work with the newer Pythons:

>>> s = "23"
>>> s in "0123456789"
True
>>> s in set("0123456789")
False

Peter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to