10.12. 👩‍💻 Tips on Handling Files¶
When working with files, there are a few things to keep in mind. When naming files, it’s best to not include spaces. While most operating systems can handle files with spaces in their names, not all can.
Additionally, suffixes in files names, for example the .txt in FileNameExample.txt
, are not magic. Instead, these
suffixes are a convention. For some operating systems the suffixes have no special significance, and only have meaning when
used in a program. Other operating systems infer information from the suffixes - for example, .EXE
is a suffix that
means a file is executable.
It’s a good idea to follow the conventions. If a file contains CSV formatted data, name it with the extension .csv
, not .txt
. A Python program will be able to read it either way, but if you follow the convention you will help other people guess what’s in the file. And you will also help the computer’s operating system to guess what application program it should open when you double-click on the file.