-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add suffix property to zipfile.Path #88261
Comments
suffix property is present on pathlib.Path (specifically pathlib.PurePath) and it could also be added to zipfile.Path for consistency. My use case is filtering files by suffix: Besides suffix also most of the other pathlib.PurePath properties and methods could be added. |
+1. The docstring says:
but only a few methods are supported. It'd be nice to have at least I'd love to work on this if the Core Devs think it makes sense and if OP is not doing so also. |
Thank for your interest Miguel. I have no experience with CPython codebase so I'll be glad if you work on this. I think treating ZipFile's like a separate drive would be the best. If we agree on this then probably all of the properties and methods from pathlib could be implemented. But without this at least If some of the properties/methods won't be implemented on zipfile.Path then it would be useful to raise The use-case for mimicking those two interfaces closely is to use both interchangeably (thanks to duck-typing). |
I prototyped something by adding Regarding the others I'm not so sure. It seems that zipfile.Path is just a convenient class to provide basic navigational operations. It's not meant to be 100% consistent with pathlib.Path. In any case, it'd nice to discuss it. Here it is: #26129 |
Sounds good to me. In general, it's easier to contribute first to https://github.com/jaraco/zipp and those changes can be readily merged into CPython. No worries, though. If these changes can be accepted here, I should be able to graft them onto jaraco/zipp as well, and thus provide the functionality for older Pythons. At this point, Python 3.10 is frozen for features, which this change would be, so I'm updating the target version to 3.11.
That's right. It's meant to provide whatever consistency makes sense, but a subset of what's available on pathlib.Path. Happy to accept any contributions that would be useful.
Indeed, perhaps the documentation should be more clear about what is and isn't supported. |
Thanks for the excellent patch. I've created jaraco/zipp#74 to track the backport of these changes. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: