2016-08-17 1:50 GMT+02:00 Guido van Rossum <gu...@python.org>: > We could expose the class with a > constructor that always fails (the C code could construct instances through > a backdoor).
Oh, in fact you cannot create an instance of os.DirEntry, it has no (Python) constructor: $ ./python Python 3.6.0a4+ (default:e615718a6455+, Aug 17 2016, 00:12:17) >>> import os >>> os.DirEntry(1) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: cannot create 'posix.DirEntry' instances Only os.scandir() can produce such objects. The question is still if it makes sense to allow to create DirEntry objects in Python :-) > Also, what does the scandir package mentioned by the OP use as the > constructor signature? The implementation of os.scandir() comes from the scandir package. It contains the same code, and so has the same behaviour (DirEntry has no constructor). Victor _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/