This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jharmse
Recipients docs@python, jharmse
Date 2022-01-17.21:03:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1642453426.31.0.937573070958.issue46419@roundup.psfhosted.org>
In-reply-to
Content
The description of classes mentions twice that methods are like C++ virtual member functions, but the truth is a bit stranger.

Even __init__ seems to act like a virtual function, so there is no guarantee that the base-class part of a derived-class instance is properly constructed.

Even if the base class __init__ is called, it may behave erratically. The object is already considered to belong to the derived class, so any method calls will resolve to the derived class. In C++, the run-time type inside any constructor or destructor always matches the compile-time type. Derived-class members are not called because those methods would attempt to use parts of the object that haven't been constructed yet or have already been destructed. Python takes no such precautions, and programmers should be warned accordingly. (I think the solution is to be very careful of calling any other method from __init__.)
History
Date User Action Args
2022-01-17 21:03:46jharmsesetrecipients: + jharmse, docs@python
2022-01-17 21:03:46jharmsesetmessageid: <1642453426.31.0.937573070958.issue46419@roundup.psfhosted.org>
2022-01-17 21:03:46jharmselinkissue46419 messages
2022-01-17 21:03:46jharmsecreate