|
From: KraftDiner on 15 Aug 2006 21:53 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?
From: Erik Max Francis on 15 Aug 2006 22:07 KraftDiner wrote: > myGlobalDictionary doesn't seem to be visible to my someClass methods. > Why? What should I do? Specify more clearly what is happening, what you wanted it to do, and why you think it's wrong? You haven't given enough information. -- Erik Max Francis && max(a)alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis Freedom is never voluntarily given by the oppressor. -- Dr. Martin Luther King, Jr.
From: Chaz Ginger on 16 Aug 2006 06:07 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? > Is it an oversight that you forgot the ':' on the getValue definition? You also forgot to do the return. I say the code should look like: def getValue(self,v) : return myGlobalDictionary[v] I am also confused as to what getVal() does. Chaz
From: Dan on 16 Aug 2006 20:16 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
|
Pages: 1 Prev: Creating Charts in Excel with pyExcelerator.ExcelMagic Next: profanity filter |