Implementing Charter
We know that the Charter library's public interface will consist of a number of functions accessed at the package level, for example charter.new_chart()
. However, using the techniques covered in the previous chapter, we know that we don't have to define our library's API in the package initialization file to make these functions available at the package level. Instead, we can define the functions elsewhere, and import them into the __init__.py
file so that they are available for others to use.
Let's start by creating a directory to hold our charter
package. Create a new directory named charter
, and create within it an empty package initialization file, __init__.py
. This gives us the basic framework within which to write our library:
Based on our design, we know that the process of generating a chart will involve the following three steps:
- Create a new chart by calling the
new_chart()
function. - Define the contents and appearance of the chart by calling...