Parsing and Extracting:
data = "From stephon.marquard@uct.ac.za Sat Jan 5 09:14:16 2008"
atpos = data.find('@')
sppos = data.find(' ', atpos)
host = data[atpos+1 : sppos]
Using in as a Logical Operator:
fruit = 'banana'
'n' in fruit >>> True
'm' in fruit >>> False
'nan' in fruit >>> True
File Handle as a Sequence:
A file handle open for read can be treated as a sequence of STRINGS where each LINE in the file is a STRING in the sequence.
xfile = open('mbox.txt')
for cheese in xfile:
print(cheese)
Reading the Whole File:
Read the whole file ( newlines and all ) into a single string.
fhand = open('mbox.txt')
inp = fhand.read()