Package Exercises

  1. Create a Package. In the previous chapter's exercises (see the section called “Refactor a Script”) are some suggestions for creating a simple module. The modules decribed in that exercise are so small that adding modules does not seem necessary. However, it's the best example of how packages arise when solving practical problems.

    Pick a module that you've already created. Add a second file with a few simple classes that do little real work. These are best described as "Hello World" classes, since they don't do anything more useful than provide a simple response to indicate that the module was imported correctly.

    Create a packge directory with the necessary __init__.py file.

    Create a demonstration script which imports and exercises both modules from this package.