From: KraftDiner on
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
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
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
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