Refactoring the code

We'll start our refactoring by moving the existing PNG renderers into a new sub-package called renderers.png. Create a new directory named png within the renderers directory, and move the title.py, x_axis.py, y_axis.py, bar_series.py and line_series.py modules into this directory. Then, create an empty package initialization file, __init__.py, inside the png directory so that Python will recognize it as a package.

There is one minor change we are going to have to make to our existing PNG renderers: because each renderer module imports the constants.py module using a relative import, we will need to update these modules so that they can still find the constants module from their new position. To do this, edit each PNG renderer ...

Get Modular Programming with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.