fileinput.input, readlines and ...
Peter Otten
__peter__ at web.de
Wed Jun 24 13:29:19 EDT 2009
Scott David Daniels wrote:
> Peter Otten wrote:
>> with open(filename) as instream:
>> lines = (line.strip() for line in lines)
>> lookup = dict(zip(lines, lines))
> Little bit of a fluff-up here.
Sorry, it should have been
with open(filename) as instream:
lines = (line.strip() for line in instream)
lookup = dict(zip(lines, lines))
> Perhaps something like:
>
> with open(filename) as instream:
> lines = (line.strip() for line in instream)
> lookup = dict(zip(lines[::2], lines[1::2]))
Tu quoque ;)
Peter
More information about the Python-list
mailing list