Read key-value pairs



examples/functional/pairs.txt
name=Foo Bar
email=foo@bar.com
address=Foo street 42

examples/functional/read_key_value_pairs.py
import sys

if len(sys.argv) != 2:
    exit(f"Usage: {sys.argv[0]}")

filename = sys.argv[1]

with open(filename) as fh:
    pairs = dict(map(lambda x: x.split('='), map(lambda s: s.rstrip("\n"), fh.readlines())))

print(pairs)

{'name': 'Foo Bar', 'email': 'foo@bar.com', 'address': 'Foo street 42'}