[Python-Dev] Re: PyNumber_Check()
Guido van Rossum
Thu, 28 Nov 2002 08:57:04 -0500
> > Maybe, as long as we all agree that that's *exactly* what they check
> > for, and as long as we agree that there may be overlapping areas
> > (where two or more of these will return True).
> > PyMapping_Check() returns true for a variety of non-mappings like
> > strings, lists, and all classic instances.
> Perhaps we should simply keep the existing semantics for
> those two APIs, that is, ensure that they return the same
> results for the standard builtin types as they did in Python 2.2
> and below ?!
That's a new way of defining their semantics, but I can agree with it!
> This would mean that a special case would have to be added
> to PyNumber_Check() to have it return False for strings
> and Unicode.
Somebody (MWH?) proposed to test for one or nb_int/nb_long/nb_float.
That makes sense to me, and should do what you ask for.
--Guido van Rossum (home page: http://www.python.org/~guido/)