[Python-ideas] Allow manual creation of DirEntry objects

Guido van Rossum guido at python.org
Tue Aug 16 19:50:15 EDT 2016


On Tue, Aug 16, 2016 at 4:14 PM, Victor Stinner <victor.stinner at gmail.com>
wrote:

> By the way, for all these reasons, I'm not really excited by Python
> 3.6 change exposing os.DirEntry ( https://bugs.python.org/issue27038
> ).
>

But that's separate from the constructor. We could expose the class with a
constructor that always fails (the C code could construct instances through
a backdoor). Exposing the type is useful for type annotations, e.g.

def is_foobar(de: os.DirEntry) -> bool: ...

and for the occasional isinstance() check.

Also, what does the scandir package mentioned by the OP use as the
constructor signature?

-- 
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20160816/5dbaeea2/attachment.html>


More information about the Python-ideas mailing list