[Numpy-discussion] [Python-3000] PEP 31XX: A Type Hierarchy for Numbers (and other algebraic entities)
Sun Apr 29 21:01:57 CDT 2007
On 4/29/07, Steven Bethard <email@example.com> wrote:
> On 4/29/07, Talin <firstname.lastname@example.org> wrote:
> > If it were technically possible, I would recommend that this PEP have to
> > run the same gauntlet that any other large library addition would, which
> > is to go through a long period of community feedback and criticism,
> > during which a large number of people actually attempt to use the
> > feature for real work.
> This sounds like a pretty good reason to add __isinstance__() and
> __issubclass__(). Then the various ABCs can be distributed as
> third-party modules but can still make sure that things like
> isinstance(42, Real) and issubclass(int, Complex) are True (or
> whatever other assertions people want to make).
Or isexample, so that we aren't locked into implementing ABCs as base classes.
def isexample(val, ABC):
def __example__(cls, val):
if val in cls.__instance: return True
if val in cls.__non_instance: return False
for instclass in type(val).__mro__:
if instclass in __class: return True
if instclass in __non_class: return False
... methods to register classes, unregister subclasses, etc
More information about the Numpy-discussion