Package rdflib :: Module Collection :: Class Collection
[show private | hide private]
[frames | no frames]

Type Collection

object --+
         |
        Collection


See 3.3.5 Emulating container types: http://docs.python.org/ref/sequence-types.html#l2h-232
>>> listName = BNode()
>>> g = Graph('IOMemory')
>>> listItem1 = BNode()
>>> listItem2 = BNode()
>>> g.add((listName,RDF.first,Literal(1)))
>>> g.add((listName,RDF.rest,listItem1))
>>> g.add((listItem1,RDF.first,Literal(2)))
>>> g.add((listItem1,RDF.rest,listItem2))
>>> g.add((listItem2,RDF.rest,RDF.nil))
>>> g.add((listItem2,RDF.first,Literal(3)))
>>> c=Collection(g,listName)
>>> print list(c)
[long(1), long(2), long(3)]

>>> 1 in c
True

>>> len(c)
3

>>> c._get_container(1) == listItem1
True

>>> c.index(Literal(2)) == 1
True

Method Summary
  __init__(self, graph, uri, seq)
  __delitem__(self, key)
...
  __getitem__(self, key)
TODO
  __iter__(self)
Iterator over items in Collections
  __len__(self)
length of items in collection.
  __setitem__(self, key, value)
TODO
  append(self, item)
  clear(self)
  index(self, item)
Returns the 0-based numerical index of the item in the list
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Method Details

__delitem__(self, key)
(Index deletion operator)

...

__getitem__(self, key)
(Indexing operator)

TODO

__iter__(self)

Iterator over items in Collections

__len__(self)
(Length operator)

length of items in collection.

__setitem__(self, key, value)
(Index assignment operator)

TODO

index(self, item)

Returns the 0-based numerical index of the item in the list

Generated by Epydoc 2.1 on Mon Oct 23 14:11:25 2006 http://epydoc.sf.net