Book Image

Daniel Arbuckle's Mastering Python

By : Daniel Arbuckle
Book Image

Daniel Arbuckle's Mastering Python

By: Daniel Arbuckle

Overview of this book

Daniel Arbuckle's Mastering Python covers the basics of operating in a Python development environment, before moving on to more advanced topics. Daniel presents you with real-world solutions to Python 3.6 and advanced-level concepts, such as reactive programming, microservices, ctypes, and Cython tools. You don't need to be familiar with the Python language to use this book, as Daniel starts with a Python primer. Throughout, Daniel highlights the major aspects of managing your Python development environment, shows you how to handle parallel computation, and helps you to master asynchronous I/O with Python 3.6 to improve performance. Finally, Daniel will teach you the secrets of metaprogramming and unit testing in Python, helping you acquire the perfect skillset to be a Python expert. Daniel will get you up to speed on everything from basic programming practices to high-end tools and techniques, things that will help set you apart as a successful Python programmer.
Table of Contents (13 chapters)

Adding static data files to the package

If we're going to add static data files to the package, where should we put them?

Well we can put them anywhere that's convenient within the package folder, but it's often a good idea to create a subfolder specifically for holding the data files. This keeps data files separate from the source code and generally makes them a little easier to work with.

The data files that are part of a package should be assumed to be read-only.

There are many reasons that might cause the files to not be writable at runtime. So, if we want to write data to a file while our code is running, we need to pick somewhere else to store it. Only files that do not change are appropriate for inclusion in a package:

ls example/
__init__.py data
ls example/data
datafile.txt
cat example/data/datafile.txt
Hello world of data

So, that said, all we have to...