diff --git a/rdflib/namespace.py b/rdflib/namespace.py index e89b06c28d..bc310167c4 100644 --- a/rdflib/namespace.py +++ b/rdflib/namespace.py @@ -142,9 +142,17 @@ def __add__(self, other): """Syntactic sugar to allow to write ns[foo] as ns + foo.""" return self[other] - def __str__(self): + def __unicode__(self): return self.__prefix__ + def __bytes__(self): + return self.__prefix__.encode('utf-8') + + if PY3: + __str__ = __unicode__ + else: + __str__ = __bytes__ + def __repr__(self): t = type(self) return "%s(%r)" % (t.__module__ + '.' + t.__name__, self.__prefix__)