Subclassing int

G gggg.iiiii at
Tue Jul 24 04:23:28 CEST 2007

Thanks a lot Matt and Steve. I replaced __int__ with __new__ and it worked

On 7/23/07, Matt McCredie <mccredie at> wrote:
> Do you guys know why the if statement is not evaluated?
> For immutable types __new__ is called before __init__. There are some
> details here: Also, it
> isn't really clear what you want to do if the value is set to None anyway.
> In your example you return None, but that simply won't work since you can't
> return anything from __init__. Perhaps your need could be met by a function
> instead:
> <code>
> def INT(x):
>     if x is None:
>         return None
>     else: return int(x)
> </code>
> -Matt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list