Namespace binding in RDFLib

  python, rdf, rdflib, turtle-rdf

In the following minimal test case:

from rdflib import Graph, Namespace, Literal, RDF

base = ""
foobar = Namespace("")
g = Graph(base=base)
g.bind('foobar', foobar)

g.add((foobar.something, RDF.type, Literal('Blah')))
g.add((foobar.something, foobar.contains, Literal('a property')))

g.add((foobar.anotherthing, RDF.type, Literal('Blubb')))
g.add((foobar.anotherthing, foobar.contains, Literal('another property')))


I get

@base <> .
@prefix foobar: <> .

<#anotherthing> a "Blubb" ;
    ns1:contains "another property" .

ns1:something a "Blah" ;
    ns1:contains "a property" .

what I’d expecte is more like

@base <> .
@prefix foobar: <> .

<#anotherthing> a "Blubb" ;
    foobar:contains "another property" .

<#something> a "Blah" ;
    foobar:contains "a property" .

So either there is something I fundamentally don’t understand about RDFLib and how to use namespaces, or there’s something funky going on.
Any thoughts, anyone?

Source: Python Questions