Modularizing the code
We have been referring to modules in the earlier chapters. An explanation is in order. A single Python file with a .py
extension is a
module. You can use this module in some other source code using an import
statement. The module name is the same as the file name, except the .py
extension. For example, if the file name is knight.py
, then import knight
will import the module into your source file.
In this section, we will split the code in the attackoftheorcs_v1_1.py
file into individual modules. You can find this file in the supporting code bundle for the previous chapter.
Attack of the Orcs v2.0.0
We will name this version 2.0.0. The major version is incremented to 2 as we are about to make some API level changes. The way we access functionality from the code will change after introduction of the new modules. Let's review the source file, attackoftheorcs_v1_1.py
, from Chapter 2, Dealing with Exceptions. The first step is to create a module (a new file) for each...