Working with Streams in Python
We are all used to working with files on disk. Reading and writing files to disk is second nature to anyone that does more with a computer than just emailing and web surfing.
Streams are representation of files in memory. Using standard file i/o, when opening and reading a file on disk, the contents are placed in memory. This "memory file" can be used to write a new file or write changes to the old one. Using the
io library, a "memory file" can be used to send the contents to other applications without ever writing them to disk.
In this lab you will get a chance to use streams to copy a file, and to provide an in-memory file for consumption by a different application.
Please Note: The contents of
book.txt was taken from Shakespeare's Sonnets.