Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import configparser
- # Helper for Name = ConfigSectionMap("SectionOne")['name']
- # Age = ConfigSectionMap("SectionOne")['age']
- def ConfigSectionMap(section):
- dict1 = {}
- options = Config.options(section)
- for option in options:
- try:
- dict1[option] = Config.get(section, option)
- except:
- print("exception on %s!" % option)
- dict1[option] = None
- return dict1
- Config = configparser.ConfigParser()
- Config.read_file(open("./tomorrow.ini"))
- Name = ConfigSectionMap("SectionOne")['name']
- Age = ConfigSectionMap("SectionOne")['age']
- print("Hello, %s. You are %s years old." % (Name, Age))
Advertisement
Add Comment
Please, Sign In to add comment