example input.dat
[settings]
port = 1234
host = abc.com
How can I parse the file, and assign
1234 to agrv[1]
,
abc.com to argv[2]
and so on
here is what i tried:
$python p.py input.dat
Traceback (most recent call last):
File "p.py", line 8, in <module>
print config['settings']['host']
AttributeError: ConfigParser instance has no attribute '__getitem__'
p.py
#!/usr/bin/env python
import sys
import ConfigParser
if __name__ == '__main__':
config = ConfigParser.ConfigParser()
config.read(sys.argv[1])
print config['settings']['host']
print config['settings']['port']
I don't want to use python3 if I can help it.