For example, the first solution in this should almost never be used, but I included it for the sake of tradition. Of course, each list comes with the caveat that not all solutions are applicable in ever scenario. If you’ve been around this series for any amount of time, you know that I like to pool together a whole series of solutions. In other words, we should find IO to be a piece of cake (with lots of caveats along the way). Basically, that means we’re going to look at some different ways to access a file for reading and writing.įortunately, Python is quite a bit less painful to work with than languages like Java or C.
Specifically, we’re going to talk about how to open a file in Python. That said, today I’ve decided to wade back out into the dark territory that is IO. In fact, I saw this issue in my file existence article from way back. As a result, you really have to take care when listing solutions because they almost certainly won’t work in all versions of Python.
To add insult to injury, Python has expanded its file support over time. They can come in many, many different shapes and sizes, and they’re never consistent across platforms.
Now, I’ve sort of avoided talking about files in this series because files are complex. Likewise, one topic that comes up a lot is Input/Output-specifically working with files. For example, a lot of people use Python for data science, so I feel some pressure to write about libraries like Pandas and Numpy. As this series grows, I find myself constantly pushed into uncomfortable domains.