Skip to main content

Working with Streams in Python

Hands-On Lab


Photo of

Training Architect





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.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.