On 16.08.16 22:35, Brendan Moloney wrote:
I have a bunch of functions that operate on DirEntry objects, typically
doing some sort of filtering
to select the paths I actually want to process. The overwhelming
majority of the time these functions
are going to be operating on DirEntry objects produced by the scandir
function, but there are some
cases where the user will be supplying the path themselves (for example,
the root of a directory tree
to process). In my current code base that uses the scandir package I
just wrap these paths in a
'GenericDirEntry' object and then pass them through the filter functions
the same as any results
coming from the scandir function.

You can just create an object that duck-types DirEntry. See for example _DummyDirEntry in the os module.


_______________________________________________
Python-ideas mailing list
[email protected]
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to