Package configuration

As you develop more sophisticated modules and packages, you will often find that your code needs to be configured in some way before it can be used. For example, imagine that you're writing a package that uses a database. To do this, your package needs to know which database engine to use, the name of the database, and the username and password to use to access that database.

You could hardwire this information into your program's source code, but doing this is a very bad idea, for two reasons:

  • Different computers and different operating systems will use different database setups. Since the information used to access the database will vary from one computer to another, anyone wanting to use your package would have to edit the ...

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.