__init__ return value

John Roth newsgroups at jhrothjr.com
Wed Sep 24 14:13:18 EDT 2003


No. __init__(self) returns None. In fact, I'm not certain whether
it even checks for the value of the return. __init__()'s function is
to initialize the instance which is it's first parameter, you cannot
change the instance it is working on.

If you need to provide your own instance object, use __new__().

John Roth


"Batista, Facundo" <FBatista at uniFON.com.ar> wrote in message
news:mailman.1064424817.693.python-list at python.org...
Studying the Tim Peter's FixedPoint code, found this:

# can we coerce to a float?
yes = 1
try:
asfloat = float(value)
except:
yes = 0
if yes:
self.__init__(asfloat, p)
return

This code is part of the __init__ method of the class.

The question is about the last two lines: When you call self.__init__(...),
doesn't it return a value that you should return too?

Thanks for all.


Facundo Batista
Gestión de Red
fbatista at unifon.com.ar
(54 11) 5130-4643
Cel: 15 5132 0132








More information about the Python-list mailing list