Enhancement: Make the path a public attribute of DirEntry #13

Closed
moloney opened this Issue Feb 22, 2014 · 4 comments

Projects

None yet

2 participants

@moloney
moloney commented Feb 22, 2014

I am finding that I often need to pass the path around with a DirEntry. It would be nice to be able to just pass around DirEntry objects as they already contain the path as a private attribute. Making it read-only seems acceptable, in which case the lstat caching wouldn't get any more complicated.

@benhoyt
Owner
benhoyt commented Feb 23, 2014

Interesting. I didn't expose that partly because the Windows DirEntry doesn't actually have it at all (even as a private attribute). Is it the path (base directory) that you're actually after, or the full path name of the file, as in os.path.join(path, entry.name)? I ask because I could make str return the full filename, so that str(entry) works as per the new pathlib standard library module (Python 3.4).

@moloney
moloney commented Feb 24, 2014

Either the base directory or the full path would be fine for my purposes. Getting the full path when converting to a string sounds good too. Thanks!

@benhoyt
Owner
benhoyt commented Jul 2, 2014

Just an update -- in the python-dev discussion on PEP 471, it looks like there's general support for this as a .full_name attribute. I'll keep you posted.

@benhoyt
Owner
benhoyt commented Jul 8, 2014

This is now the DirEntry.full_name attribute, included in scandir version 0.6 which I just uploaded to PyPI.

@benhoyt benhoyt closed this Jul 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment