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


On 7/23/07, Matt McCredie <[EMAIL PROTECTED]> 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: http://docs.python.org/ref/customization.html. 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



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to