[Python-Dev] py3k: TypeError: object.init() takes no parameters (original) (raw)

Terry Reedy tjreedy at udel.edu
Sat Jan 17 03:20:59 CET 2009


Nick Coghlan wrote:

Terry Reedy wrote:

So I wonder whether the proper change might have been to remove object.init. That would have broken too much code, since a lot of immutable types rely on it (they only override new and leave init alone).

In what way do they depend on the equivalent of "def f(): pass"? If, during the object creation process, "if hasattr(newob, 'init'):" were added after calling cls.new and before calling newob.init, what dependency would be left?

To repeat a previous comment, the doc sentence beginning "If a base class has an init() method," implies that it is intended to be possible for classes to not have an init method. Should the doc be changed. Is this just a holdover from pre-object-class days?

For more info, see Guido's checkin changing the behaviour and the associated tracker issue: http://svn.python.org/view?rev=54539&view=rev http://bugs.python.org/issue1683368

Ah yes. In that thread I complained that

object.init.doc 'x.init(...) initializes x; see x.class.doc for signature'

unchanged in 3.0) is uninformative. Why cannot object.init.doc tell the truth?

"object.init(self) takes no other args and does nothing"

The signature of a class as a callable is not the signature of its init method!

In particular

object.class.doc "type(object) -> the object's type\ntype(name, bases, dict) -> a new type"

(also unchanged in 3.0) is irrelevant and uninformative as to whether object.init accepts (as it used to) or rejects (as it now does) args other than 'self'.

Terry Jan Reedy



More information about the Python-Dev mailing list