Re: [Python-Dev] quick poll: could int, str, tuple etc. become type objects?
6 Jun
2001
6 Jun
'01
5:14 a.m.
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 253. --Guido van Rossum (home page: http://www.python.org/~guido/)
8354
Age (days ago)
8354
Last active (days ago)
0 comments
1 participants
participants (1)
-
Guido van Rossum