Coding 101 16

Python - The External Data Circle of Life

Welcome to Coding 101 - It's the TWiT show that gives YOU the knowledge to live in the wonderful world of the programmer. This week we are introducing our newest module, Python with Code Warrior Dale Chase!

Ivory Tower: External File IO

open()
This function opens a file with the flags and mode of your choosing. For simplicity, we're only using the "r" "w" modes.
-- The "r" mode opens a file for "read only" use
-- The "w" mode blanks the file prepares to write to the file
* Note that this function DOES NOT READ THE FILE INTO A VARIABLE.

USAGE:
text_file = open("/Users/PadreSJ/Desktop/C101-16/write.txt", "r")
# This opens a file called "write.txt" in READ-ONLY mode and sets the pointer in variable "text_file"

text_file = open("/Users/PadreSJ/Desktop/C101-16/write.txt", "w")
# This opens a file called "write.txt" in WRITE MODE, sets the pointer in variable "text_file" and blanks that file.

read()
This function reads the contents of the file into a string variable.