I'm a noob in Python
Problem: Find and replace Keys(strings) in files
For this I'm using Python ConfigParser. But I want to read the whole config (.ini) file into dictionary at once regardless of sections.
- Is it possible?
- Is it OK to do so?
I don't want to read a single section at a time
dict(Config.items('Section'))
Don't want to traverse the sections
for each_section in conf.sections():
for (each_key, each_val) in conf.items(each_section):
print each_key
print each_val
What other options am I left with?
------- Edit 1 -------
Config.ini
[Common]
home_dir: /Users
library_dir: /Library
system_dir: /System
macports_dir: /opt/local
[Frameworks]
Python: 3.2
path: ${Common:system_dir}/Library/Frameworks/
[Arthur]
nickname: Two Sheds
last_name: Jackson
my_dir: ${Common:home_dir}/twosheds
my_pictures: ${my_dir}/Pictures
python_dir: ${Frameworks:path}/Python/Versions/${Frameworks:Python}
Below is the file which contains the keys that are to be repalced
my dir is home_dir
my lib dir is library_dir
python path is path
My pictures are placed at my_pictures