Topic 3 - Persistence & Inheritance Flashcards
File Input and Output
The process of opening a file, processing it by writing or reading data, and closing the file
Persistence
The ability of a program to save data for later use
Binary files
Data not encoded as text, not human readable
Text files
Data encoded as text as a series of characters, human readable
Sequential Access
Accessing data from the beginning of the file to the end of the file
Direct Access
Jumping directly to any piece of data in the file without reading the data that comes before it
File object
An object associated with a specific file that provides a way for the program to work with the file
Open() function
Used to open a file, given its file name and the operation mode
‘r’ mode
Read mode, file cannot be changed
‘w’ mode
Write mode, new file will be created
‘a’ mode
Append mode, data will be appended to the end of the file
write() method
Used to write a string to the file
close() method
Used to close the file object
read() method
Used to read the entire content from the file
readline() method
Used to read line by line from the file