Improve Namespace attribute handling #1586
Replies: 4 comments 1 reply
-
hmm, in that case what about basing on I mean there is a certain convenience in basing on In [1]: from rdflib import URIRef, Literal
INFO:rdflib:RDFLib Version: 4.2.2-dev
In [2]: import json
In [3]: json.dumps([URIRef('http://foo.bar'), Literal('http://foo.bar')])
Out[3]: '["http://foo.bar", "http://foo.bar"]' (The above should actually throw a I know that |
Beta Was this translation helpful? Give feedback.
-
Yes, I agree, this is definitely worth discussing. Hopefully reliance on the unicode convenience isn't that widespread, or at least amenable enough for such a change to be accepted for 5.0. (Although with enough of such fixes, we might be better off considering something like an |
Beta Was this translation helpful? Give feedback.
-
Ditching unicode inheritance from Namespace seems tempting. I am less convinced about ditching it from everything. More because it will be a lot of work and will introduce a lot of bugs that we don't really have the developer resources to fix. Maybe when @joernhees has finished his PhD? :) I wonder what we gain by having things inherit from unicode code. Off the top of my head I cannot think of that many things this enables that I actively use? Pros:
Cons:
|
Beta Was this translation helpful? Give feedback.
-
Is this still an issue? |
Beta Was this translation helpful? Give feedback.
-
Since
rdflib.namespace.Namespace
inherits fromunicode
, certain vocabulary names clashes with methods on unicode objects, and have to be accessed using__getitem__
(e.g.NS['upper']
) instead ofNS.upper
.A possible improvement (for 5.0, since it would be backwards incompatible) would be to either just not inherit from
unicode
, or to add something like:to
Namespace
. Any need to useunicode
methods on aNamespace
instance would then have to be done usingunicode(DCTERMS).title()
(orunicode.title(DCTERMS)
if its inheritance is kept).Beta Was this translation helpful? Give feedback.
All reactions