Alex Martelli wrote: > I'll be happy to draft a PEP if needed (and just as happy to > eventually provide an implementation patch if the PEP's accepted), > but wanted to doublecheck on the general issue first!
I haven't really followed the earlier basenumber discussions (aside from the sidetrack into the nature of mappings), but why would we want this ability as a typecheck and not some form of interface check? For example, what's wrong with "hasattr(x, __int__)"? That works for all the builtin types, and, IMO, anyone defining a direct conversion to an integer for a non-numeric type deserves whatever happens to them. Something like: def is_number(x): return hasattr(x, '__int__') def is_integer(x): return x == int(x) Requiring inheritance from "basenumber" in order to make something behave like a real number seems antithetical to both duck-typing and the adaptation PEP. Cheers, Nick. -- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://www.boredomandlaziness.org _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com