Reusable code is great, but a shareable module is better. By sharing your code as a Python module, you open up your code to the entire Python community...and it’s always good to share, isn’t it? In this chapter, you’ll learn how to create, install, and distribute your own shareable modules. You’ll then load your module onto Python’s software sharing site on the Web, so that everyone can benefit from your work. Along the way, you’ll pick up a few new tricks relating to Python’s functions, too.
You’ve been showing your function to other programmers, and they like what they see.
Yes, a function this good should be shared with the world.
Python provides a set of technologies that make this easy for you, which includes modules and the distribution utilities:
Modules let you organize your code for optimal sharing.
The distribution utilities let you share your modules with the world.
Let’s turn your function into a module, then use the distribution utilities to share your module with the wider Python programming community.
A module is simply a text file that contains Python code. The main requirement is that the name of the file needs to end in
.py: the Python extension. To turn your function ...