Fortran hash table  0.1
 All Classes Namespaces Files Functions Variables
read_write.py
Go to the documentation of this file.
1 """
2 Read a "equal sign" separated input file
3 """
4 from __future__ import print_function
5 
6 ## \file read_write.py
7 # \brief Using a dict to store a configuration file
8 #
9 # The purpose of this code is a comparison to read_write.f90
10 
11 import argparse
12 
13 parser = argparse.ArgumentParser(description=__doc__)
14 parser.add_argument('file')
15 args = parser.parse_args()
16 
17 d = {}
18 
19 with open(args.file, 'r') as f:
20  for l in f.readlines():
21  l = l.strip()
22  if '=' in l:
23  k, v = l.split('=')
24  d[k.strip()] = v.strip()
25 
26 for k, v in d.items():
27  print(k, '=', v)
28