1/30
Vocabulary and concepts relating to file input/output operations, data processing, and exception handling in Python, based on Chapter Six and Tony Gaddis's 'Starting Out with Python'.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
Writing to a file
The process of saving data in a file by copying a piece of data from RAM to the file.
Output file
The term used for a file that is being written to.
Reading data from a file
The process of retrieving data from a file by copying it to RAM and referencing it with a variable.
Input file
The term used for a file from which data is being read.
Opening a file
The first step in dealing with files that creates a connection between the file and the program.
Closing a file
The final step in dealing with files that disconnects the file from the program and clears the memory buffer area.
Text files
Files containing data encoded using schemes like ASCII or Unicode, where even numbers are stored in character format.
Binary files
Files containing data that has not been converted to text and is intended only for a program to read.
Sequential access
A file access method where data is read from beginning to end; you must read all preceding data to reach a middle piece.
Direct access (random access)
A file access method that allows jumping directly to any piece of data in the file.
Filename Extensions
The three characters following a filename that usually indicate the type of file, such as .jpg, .txt, or .doc.
File object
An object created in memory associated with a specific file that provides a link for the program to the file through a variable.
open function
A function in Python used to create a file object; follows the general format file_variable = open (filename, mode).
Mode 'r'
A Python file mode used to open a file for reading only; the file cannot be changed or written to.
Mode 'w'
A Python file mode used to open a file for writing; it erases content if the file exists or creates a new one if it does not.
Mode 'a'
A Python file mode used to open a file for appending data to its end; it creates the file if it does not exist.
Raw string (r'')
A string prefix used when specifying file paths to tell the interpreter to read backslashes literally as backslashes.
Method
A function that belongs to an object and performs some operation using that object.
write method
A file object method used to write a string of data to a file.
read method
A file object method that reads the entire contents of a file into memory as a string.
readline method
A file object method that reads an individual line, including the \n character, from a file.
Read position
An internal value maintained by Python that marks the location of the next item to be read from a file.
rstrip method
A string method used to remove characters from the right side of a string, often used to remove the \n newline character.
str function
A Python function used to convert a number to a string, which is necessary before writing numeric data to a text file.
Record
A complete set of data in a file consisting of one or more fields.
Field
A single piece of data within a record.
Exception
An error that occurs while a program is running, causing the program to abruptly halt.
Exception handler
Code written with a try/except statement that responds to exceptions and prevents a program from crashing.
IOError
A specific type of exception that can occur if, for example, a file being opened for reading does not exist.
ValueError
An exception raised when an attempt to convert a string to a numeric type (like int or float) fails.
finally clause
An optional clause in a try/except suite that executes regardless of whether an exception was thrown, used for post-exception cleanup.