Bug or Feature?

Stephan Diehl stephan.diehl at gmx.net
Mon Nov 24 09:44:59 EST 2003


Michele Simionato wrote:

> Stephan Diehl <stephan.diehl at gmx.net> wrote in message
> news:<bpsik5$ni7$07$1 at news.t-online.com>...
>> I was playing around with defining new types and have seen the
>> following behaviour:
>> 
>> Python 2.3.1
>> ============
>>  
>> >>> class Int(int):pass
>>  ...
>> >>> a = Int(7)
>> >>> b = Int(8)
>> >>> c = a + b
>> >>> type(c)
>> <type 'int'>
>> 
>> Basicly: Int is not closed under it's defined operations. :-(
>> 
> 
> You want my "innermethods" module. Originally I wrote it as a recipe
> for the cookbook, but then I forgot to post it ;)
> 

Yes, thanks, this is most helpfull.

Although, the question was more along the line, if (in the light of the
principle of least surprise) this behaviour makes sense.
My private opinion would be, that the usefullness of builtin types as real
types would be much better, if they were safe under inheritance.




More information about the Python-list mailing list