Storing the configuration in PY files
The PY file format means using Python code as the configuration file as well as the language to implement the application. We will have a configuration file that's simply a module; the configuration is written in the Python syntax. This removes the need to parse the module.
Using Python gives us a number of design considerations. We have two overall strategies to use Python as the configuration file:
A top-level script: In this case, the configuration file is simply the top-most main program
An exec() import: In this case, our configuration file provides parameter values that are collected into module global variables
We can design a top-level script file that looks like the following code:
from simulator import * def simulate_SomeStrategy_Flat(): dealer_rule= Hit17() split_rule= NoReSplitAces() table= Table( decks=6, limit=50, dealer=dealer_rule, split=split_rule, payout=(3,2) ) player_rule= SomeStrategy() betting_rule= Flat...