making your own DirEntry.

Antoon Pardon antoon.pardon at vub.be
Fri Dec 22 07:00:52 EST 2023


I am writing a program that goes through file hierarchies and I am mostly
using scandir for that which produces DirEntry instances.

At times it would be usefull if I could make my own DirEntry for a specific
path, however when I try, I get the following diagnostic:

>>> os.DirEntry('snap')
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
TypeError: cannot create 'posix.DirEntry' instances


Does anyone have an idea for why this limitation and how to go around it.

At this moment I don't consider pathlib very usefull, it lacks the
follow_symlinks parameter in the is_dir, is_file, ... methods.

-- 
Antoon Pardon.



More information about the Python-list mailing list