Return to Snippet

Revision: 28709
at July 13, 2010 03:29 by magicrebirth


Initial Code
In [24]: from rdflib import RDF

In [25]: from rdflib import 
BNode              IIdentifier        Node               StringInputSource  _logger            exceptions         sparql             
ConjunctiveGraph   Identifier         QueryResult        URIRef             classImplements    interfaces         store              
FileInputSource    Literal            RDF                URLInputSource     compat             logging            syntax             
Graph              Namespace          RDFS               Variable           events             plugin             

In [25]: from rdflib import RDFS


In [26]: RDFS.su
RDFS.subClassOf     RDFS.subPropertyOf  

In [26]: for x in g.triples((None, rdftype, owlclass)):
   ....:     f = x
   ....:     
   ....:     

In [27]: f
Out[27]: 
(rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl#node'),
 rdflib.URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
 rdflib.URIRef('http://www.w3.org/2002/07/owl#Class'))

In [28]: type(f)
Out[28]: <type 'tuple'>


In [29]: f[0]
Out[29]: rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl#node')

In [30]: type(_)
Out[30]: <class 'rdflib.URIRef.URIRef'>

In [31]: u = f[0]

In [32]: u.
u.__add__           u.__gt__            u.__new__           u.abstract          u.index             u.ljust             u.rsplit
u.__class__         u.__hash__          u.__providedBy__    u.capitalize        u.isalnum           u.lower             u.rstrip
u.__contains__      u.__implemented__   u.__provides__      u.center            u.isalpha           u.lstrip            u.split
u.__delattr__       u.__init__          u.__reduce__        u.concrete          u.isdecimal         u.md5_term_hash     u.splitlines
u.__doc__           u.__le__            u.__reduce_ex__     u.count             u.isdigit           u.n3                u.startswith
u.__eq__            u.__len__           u.__repr__          u.decode            u.islower           u.partition         u.strip
u.__ge__            u.__lt__            u.__rmod__          u.defrag            u.isnumeric         u.replace           u.swapcase
u.__getattribute__  u.__mod__           u.__rmul__          u.encode            u.isspace           u.rfind             u.title
u.__getitem__       u.__module__        u.__setattr__       u.endswith          u.istitle           u.rindex            u.translate
u.__getnewargs__    u.__mul__           u.__slots__         u.expandtabs        u.isupper           u.rjust             u.upper
u.__getslice__      u.__ne__            u.__str__           u.find              u.join              u.rpartition        u.zfill

In [32]: u.abstract
Out[32]: <bound method URIRef.abstract of rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl#node')>

In [33]: u.abstract()
Out[33]: rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl#node')

In [35]: u.concrete()
Out[35]: rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl/node')

In [36]: u.defrag()
Out[36]: rdflib.URIRef('http://cohereweb.net/ontology/cohere.owl')

In [37]: u.__str__()
Out[37]: 'http://cohereweb.net/ontology/cohere.owl#node'

In [38]: u.n3()
Out[38]: u'<http://cohereweb.net/ontology/cohere.owl#node>'

Initial URL
http://www.rdflib.net/rdflib-2.4.0/html/index.html

Initial Description

                                

Initial Title
RDFLIB: playing with URIRef objects

Initial Tags
python

Initial Language
Python