-
Notifications
You must be signed in to change notification settings - Fork 564
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
Adding Namespace.__contains__() #1237
Adding Namespace.__contains__() #1237
Conversation
Hey @JaimieMurdock, thank you for submitting a pull-request. I understand your motivation but I'm unsure if this extra code is worth the convenience as |
I'll add the The major motivator is "Readability counts." from PEP 20. Also, was the "natural" way of writing it for a relatively-new-to-Python student working on the project. |
Starting to peel back the layers on Namespace management and there's quite a bit of counter-intuitive typing - had to add a method to |
Worth noting that #597 proposed the |
I'm happy for any considered work to make any Pythonic ways of querying RDFlib objects work. I suspect that work to implement this function, even if the use of the output is essentially the same as the startwith way of working, will address inconsistencies or old coding styles in the code base so it is worth it. So, if you're prepared to dive into Namespace to implement stuff and the PR passes all tests, great! |
I'll close this PR and re-open it to hopefully trigger Drone to see the PR and run its tests. |
Nope, looks like Drone only kicks in for new pull requests. |
No issue for this, just a quick addition for usability/literacy while working with the library.
Proposed Changes
Namespace.__contains__()
method to enable syntax sugar ofref in ns
. This is a natural way to discover if an arbitraryURIRef
is in theNamespace
.ref.startswith(ns)
, which doesn't preserve semanticsThis has possible extension to
NamespaceManager
, testing if aURIRef
is in any managed namespace.Note that in
NamespaceManager
, namespaces are stored asURIRef
s, notNamespace
objects :/Hoping this starts a discussion about some usability concerns.