OOSet (was Re: [ZODB-Dev] simple newbie BTrees.Length question
Bakhtiar A Hamid
kedai at kedai.com.my
Tue Jan 20 05:01:18 EST 2004
thanks guys for the pointers.
now, i'm trying to figure out OOSet.
i'm a bit embarassed with the naivity of my questions. please pardon my
ignorance
is there any logic in this class? i want to store a list/seq, and thought of
using OOBTree. however, chrism pointed out that OOBTree is best for
mapping/dict.
i store a list in OOSet, and just return OOSet[0] to my calling object.
so i muck around with OOSet. pointers/comments welcome
class Mystuff:
def __init__(self):
self.id=time.time()
self.stuff=OOSet()
self.getStuff=self.gStuff()
def doStuff(self, v=[]):
self.stuff.insert(v)
self.getStuff=self.gStuff()
def gStuff(self):
if self.stuff.__len__()>0:
return list(self.stuff)[0]
>>> import Mystuff
>>> x=Mystuff.Mystuff()
>>> x
<Mystuff.Mystuff instance at 0x81dfe6c>
>>> x.stuff
OOSet([])
>>> x.getStuff
>>> x.doStuff(['this is one','this is two'])
>>> x.stuff
OOSet([['this is one', 'this is two']])
>>> x.getStuff
['this is one', 'this is two']
More information about the ZODB-Dev
mailing list