This is the section of this chapter that we all have been waiting for; we are going to create the application entry point and glue together all the pieces of code that we have written so far.
Let's create a file called __main__.py
in the currency_converter/currency_converter
directory. We have already used the _main__
file before in Chapter 1, Implementing the Weather Application. When we place a file called __main__.py
in the module's root
directory, it means that that file is the entry script of the module. So, if we run the following command:
python -m currency_converter
It is the same as running:
python currency_converter/__main__.py
Great! So, let's start adding content to this file. First, add some import
statements:
import sys from .core.cmdline_parser import parse_commandline_args from .config import get_config from .core import DbClient from .core import fetch_exchange_rates_by_currency
We import the sys
package as usual in case we need to call exit...