[Tutor] How to populate a dictionary
Alan Gauld
alan.gauld at btinternet.com
Thu Jul 17 16:58:01 CEST 2008
"Michiel Overtoom" <motoom at xs4all.nl> wrote
> Let me suggest some improvements. You can process all the lines in a
> textfile like this:
>
> for line in open("dates.txt").readlines():
> print line
Or just
for line in open("dates.txt"):
print line.rstrip()
> So, your little homework program becomes more pythonic like this:
Spoilsport, you showed him the answer! :-)
Alan G
More information about the Tutor
mailing list