Cannot Access Dictionary

apjewell at apjewell at
Sat Mar 25 01:04:31 CET 2000

Well, I tried everything I could think of and couldn't figure this one
out.  I'm a new user so maybe it's something easy - any help would be
greatly appreciated.

I have a class that reads in a configuration file.  The configuration
file is separated into sections, each section becomes an element in the
AppInfo array.

Each element in a section is entered as a key:value dictionary entry.
So all of my juicy data is contained in the AppInfo array (E.G.,
self.AppInfo[0]["KeyName"] = "Value").  I have an access function called
GetEnvList which looks like this:

   def GetEnvList(self, *ReqEnvName):
      Name: GetEnvList
      Desc: An access method to return a list[] describing all the
            environments listed in the configuration file.  These
      # If ReqEnvName exists
      if ReqEnvName:
         print "Requested Name is: %s--" % (ReqEnvName)
         EnvData = self.AppInfo[self.secEnv].get(ReqEnvName,
            "That environment was not found in this configuration

         EnvData = self.AppInfo[self.secEnv]

      return EnvData

My class is called AppInCM.  There's the setup - NOW, if I import this
class interactively I CAN successfully access a specific environment by

myClass.AppInfo[self.secEnv].get("KeyName", "Couldn't get it")
or, for simplicity, myClass.AppInfo[1]["KeyName"].

But whenever I use my handydandy GetEnvList("KeyName") function, the
entry can't be found, e.g.:
>>> myC.GetEnvList("Development")
Requested Name is: Development
'That environment was not found in this configuration file.'

Does anyone have any idea what this might be?  The function works fine
without the parameter, i.e., myC.GetEnvList() will return the entire
array of dictionary entries.  I can access my entries WITHOUT the
function so I know they're load OK.  What gives??  Thanks for your time!

Andy Jewell

Sent via
Before you buy.

More information about the Python-list mailing list