Menu

#1 Merging of options doesn't seem to work with dicts

open
nobody
None
5
2005-03-13
2005-03-13
No

This example consists of three files: main.py, myConfig.py, and
newConfig.py.

I have told the Config constructor to suck up both config files on
initialization. Here's the program output:

~/show->python ./main.py
{'xGenDir': 'gen'}
Hi there!

I expected to see both the GenDir and xGenDir keys in localConfig.

# main.py
import sys
import os
from config import Config

def main():
pass

if __name__ == '__main__':
configObject = Config( ['myConfig.py', 'newConfig.py'] )
print configObject.get( 'localConfig' )
print configObject.get('foo')

# myConfig.py
class _dict(dict):
pass

# this should be able to be added to
localConfig = \ {
'default' : _dict(
GenDir = "gen"
)
}

foo = "Hi there!"

# newConfig.py
class _dict(dict):
pass

localConfig = \ {
'default' : _dict(
xGenDir = "gen"
)
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.