[Python-Dev] Type/class differences (Re: Sets: elt in dict, lst.include)
Thomas Wouters
thomas@xs4all.net
Tue, 6 Feb 2001 15:57:12 +0100
On Mon, Feb 05, 2001 at 11:04:22AM -0800, Neil Schemenauer wrote:
> On Mon, Feb 05, 2001 at 01:37:39PM -0500, Guido van Rossum wrote:
> > Now, can you do things like this:
> [example cut]
> No, it would have to be written like this:
> >>> from types import *
> >>> class MyInt(IntType): # add a method
> def add1(self): return self.value+1
Why ? Couldn't IntType do with an __add__[*] method that does this ugly magic
for you ? Same for __sub__, __int__ and so on.
*] Yes, yes, I know, it's a type, not a class, but you know what I mean :)
--
Thomas Wouters <thomas@xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!