import StringIO

# Arbitrary String
message = 'This is just a normal string.'

# Use StringIO method to set as file object
f = StringIO.StringIO(message)

"""
Explanation: StringIO
The StringIO module implements an in-memory file like object. This object can then be used as input or output to most functions that would expect a standard file object.
The best way to show this is by example:
End of explanation
"""


f.read()

"""
Explanation: Now we have an object f that we will be able to treat just like a file. For example:
End of explanation
"""


f.write(' Second line written to file like object')

# Reset cursor just like you would a file
f.seek(0)

# Read again
f.read()

"""
Explanation: We can also write to it:
End of explanation
"""


