
Sign up to save your podcasts
Or


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!
To see all the code used in today's episode, go to Our Github Repository for Module 2
Ivory Tower: External File IOUsing external data reqires knowledge of four functions: "open()", " read()", "write()" and "close()"
open()
This function opens a file with the flags and mode of your choosing. For simplicity, we're only using the "r" "w" modes.
* Note that this function DOES NOT READ THE FILE INTO A VARIABLE.
USAGE:
text_file = open("/Users/PadreSJ/Desktop/C101-16/write.txt", "r")
text_file = open("/Users/PadreSJ/Desktop/C101-16/write.txt", "w")
read()
This function reads the contents of the file into a string variable.
USAGE:
textFromFile = text_file.read()
write()
This function writes a string into an external file.
USAGE:
text_file.write(MyString)
close()
This function closes access to the file. USAGE: text_file.close() #This closes the file indexed at "text_file"
Hosts: Fr. Robert Ballecer, SJ and Shannon Morse
Guest: Dale Chase
Bandwidth for Coding 101 is provided by CacheFly.
Sponsors:
By TWiT4
44 ratings
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!
To see all the code used in today's episode, go to Our Github Repository for Module 2
Ivory Tower: External File IOUsing external data reqires knowledge of four functions: "open()", " read()", "write()" and "close()"
open()
This function opens a file with the flags and mode of your choosing. For simplicity, we're only using the "r" "w" modes.
* Note that this function DOES NOT READ THE FILE INTO A VARIABLE.
USAGE:
text_file = open("/Users/PadreSJ/Desktop/C101-16/write.txt", "r")
text_file = open("/Users/PadreSJ/Desktop/C101-16/write.txt", "w")
read()
This function reads the contents of the file into a string variable.
USAGE:
textFromFile = text_file.read()
write()
This function writes a string into an external file.
USAGE:
text_file.write(MyString)
close()
This function closes access to the file. USAGE: text_file.close() #This closes the file indexed at "text_file"
Hosts: Fr. Robert Ballecer, SJ and Shannon Morse
Guest: Dale Chase
Bandwidth for Coding 101 is provided by CacheFly.
Sponsors:

202 Listeners

78 Listeners

355 Listeners

8 Listeners

3 Listeners

7 Listeners

3 Listeners