Delineating a Read File
Question: Not really too sure how to word this question, therefore if you don't
particularly understand it then I can try again.

I have a file called _example.txt_ and I'd like to import this into my Python
program. Here I will do some calculations with what it contains and other
things that are irrelevant.

Instead of me importing this file, going through it line-by-line and
extracting the information I want.. can Python do it instead? As in, if I
structure the _.txt_ correctly (whether it be key / value pairs seperated by
an equals on each line), is there a current Python 'way' where it can handle
it all and I work with that?


Answer: 
    with open("example.txt") as f:
        for line in f:
            key, value = line.strip().split("=")
            do_something(key,value)
    

looks like a starting point if I understand you correctly. You need Python 2.6
or 3.x for this.

Another place to look is the `csv` module that can parse comma-separated value
files - and you can tell it to use `=` as a separator instead. This will
abstract away some of the "manual work" in that previous example - but it
seems your example doesn't especially need that kind of abstraction.

Another idea:

    
    
    with open("example.txt") as f:
        d = dict([line.strip().split("=") for line in f])
    

Now that's concise and pythonic :)

