[issue25415] I can create instances of io.IOBase

Terry J. Reedy report at bugs.python.org
Fri Oct 16 23:37:21 EDT 2015


Terry J. Reedy added the comment:

Martin, I agree with changing the doc. Gerrit misunderstood because 'no public constructors' is either meaningless or wrong.  We do not usually talk about public versus private constructors.  This sounds more like C++ than Python.

For Python namespaces, names that start with '_' are private by convention unless documented otherwise.  Special names (__x__) are private in the sense that they are not usually used except by methods of the class; special methods are usually accessed by syntax or public names.  For class C, the default constructor is C.__new__, accessed by calling C.  (Let us not worry about other methods here.)  If C is a public name, with no '_', as is 'IOBase', then to me it has/is a public constructor.  Like other classes, IOBase has .__new__ and calling it produces an instance, as Gerrit discovered.  In that sense, it is not truly abstract.

I believe 'has no public constructor' is intended to mean 'has no documented signature and should not be *directly* called."  (If subclasses do call the base, then the signature should be documented.)

----------
nosy: +terry.reedy

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25415>
_______________________________________


More information about the Python-bugs-list mailing list