KraftDiner wrote: > I have a question.. > > myGlobalDictionary = dictionary() > > > class someClass: > def __init__(self): > self.x = 0; > def getValue(self, v) > myGlobalDictionary.getVal(v) > > > myGlobalDictionary doesn't seem to be visible to my someClass methods. > Why? What should I do? >
This works: >>> class dictionary(dict): ... def getVal(self, key): ... return self[key] ... >>> myGlobalDictionary = dictionary() >>> >>> myGlobalDictionary['spam'] = 'eggs' >>> >>> class someClass: ... def __init__(self): ... self.x = 0; ... def getValue(self, v): ... return myGlobalDictionary.getVal(v) ... >>> >>> mySomeThing = someClass() >>> >>> print mySomeThing.getValue('spam') eggs >>> -- dedded att verizon dott net -- http://mail.python.org/mailman/listinfo/python-list