[caiman-discuss] Distro-constructor finalizer with messages through sockets
Jack Schwartz
Jack.A.Schwartz at Sun.COM
Mon Mar 3 13:55:45 PST 2008
Dave Miner wrote:
> Jack Schwartz wrote:
>> HI Dave.
>>> With respect to the new file, why is isNumberType() not sufficient
>>> for what you're doing?
>>>
>> Thanks for the tip. I didn't know about isNumberType(). I have
>> rewritten isnumber() as follows:
>>
>> import operator
>>
>> def isnumber(arg):
>> try:
>> if operator.isNumberType(int(arg, 0)):
>> return True
>> except:
>> pass
>> try:
>> if operator.isNumberType(float(arg)):
>> return True
>> except:
>> pass
>> return False
>>
>
> Are there any exceptions actually possible here that would require
> catching?
Yes. Many. In particular,
- If you give a floating point or any non-int string to the int typecast.
- If you give an int or non-floating-point string to the float typecast.
This is exactly the type of thing this method is supposed to figure out.
Thanks,
Jack
More information about the caiman-discuss
mailing list