[Python-Dev] quick poll: could int, str, tuple etc. become type objects?

Guido van Rossum guido@digicool.com
Tue, 05 Jun 2001 17:14:07 -0400

> Is the intent of using int and friends as constructors instead of just
> coercion functions that I should (eventually) be able to do this:
>     class NonNegativeInt(int):
>         def __init__(self, val):
> 	    if int(val) < 0:
> 	        raise ValueError, "Value must be >= 0"
> 	    int.__init__(self, val)
> 	    self.a = 47
>         ...
> ?

Yes, sort-of.  The details will be slightly different.  I'm not
comfortable with letting a user-provided __init__() method change the
value of self, so I am brooding on a work-around that separates
allocation and one-time initialization from __init__().  Watch PEP

--Guido van Rossum (home page: http://www.python.org/~guido/)