Permalink
Browse files

Fix bug in __getitem__

__getitem__ would return None for any 3-tuples. It now does the
expected thing, casting when necessary.
  • Loading branch information...
1 parent 4fd86b7 commit 881d8925c60c789f2cd2f7cecc61f913fc4814cf @theepicsnail committed Mar 7, 2011
Showing with 5 additions and 4 deletions.
  1. +5 −4 Configuration.py
View
@@ -21,7 +21,7 @@ def __getitem__(self,arg):
elif len(arg)==1:
return self._Config.items(*arg)
elif len(arg)==3:
- exp = type(arg[2])
+ exp = arg[2]
narg = arg[:2]
if exp==str: return self._Config.get(*narg)
elif exp==bool: return self._Config.getboolean(*narg)
@@ -38,12 +38,13 @@ def __iter__(self):
yield i
if __name__=="__main__":
- cf = ConfigFile("Core")
+ cf = ConfigFile("Foo")
for section in cf:
print section
for item in cf[section]:
print item
-
-
+ print cf["Section1","arg2",int]
+ print cf["Section1","arg2",bool]
+ print cf["Section2","arg1",str]

0 comments on commit 881d892

Please sign in to comment.