Download presentation
Presentation is loading. Please wait.
Published byToby Daniels Modified over 8 years ago
1
Files in Python When does it crash?
2
How a file can make a program crash For input files, there are several things that can happen which can cause a program to crash Some are avoidable with some care, some are not the file does not exist that you are trying to open trying to read past the end of the file the data in the file is not laid out as the program expects the file exists but is empty
3
Output files An output file is constructive and destructive If the file you are opening to write to does NOT exist, it is created Note that if you gave the path to the folder as part of the file name, the open will NOT create folders! In other words, outfile = open(“c:\\My Documents\\cs115\\file1.txt”, “w”) will only work if the path already exists and you have permission to write to it If the file you are opening to write to DOES exist already, all data is destroyed tells the OS to set the length of the file to zero bytes! If you try to write to a medium that is full, your program will crash
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.