A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-June/015286.html below:

could int, str, tuple etc. become type objects?

[Python-Dev] quick poll: could int, str, tuple etc. become type objects? [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
253.

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



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4