isNumber? check
Aahz
aahz at pythoncraft.com
Thu Oct 2 09:22:54 EDT 2003
In article <3F79D3B4.DBE550CC at alcyone.com>,
Erik Max Francis <max at alcyone.com> wrote:
>Jean-S?bastien Bolduc wrote:
>>
>> If the "__int__" method is defined for "x", it is a number. This will
>> work for integer, long, float and complex types, as well as for custom
>> classes that emulate numeric types.
>
>This is an insidiously bad idea, in my opinion. All having an __int__
>method means is there is some _conversion_ from an instance to an int
>type. It does not at all mean the custom instance spends most of its
>life behaving as an integer.
Yup. There's been some talk of adding an __index___() method or
something to deal with that.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan
More information about the Python-list
mailing list