Skip to content

Instantly share code, notes, and snippets.

@metaperl
Created October 10, 2014 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metaperl/c87ed65397704e949886 to your computer and use it in GitHub Desktop.
Save metaperl/c87ed65397704e949886 to your computer and use it in GitHub Desktop.
parameter binding
I'm wondering if there is a Python module/class which aids parameter binding. The parameters will be bound from the command line and presumably set the parameters within a module, with the correct type, converting from the command line string to actual type
Here is a an example:
shell> share_trader.py
Welcome to Share Trader
=======================
parms: amount_to_spend=1000, symbol=None, stop_loss_percent=10, profit_percent=5
Once all unbound parameters are bound, trading will begin:
share_trader_shell> amount_to_spend=500
Parameter set.
parms: amount_to_spend=1000, symbol=None, stop_loss_percent=10, profit_percent=5
share_trader_shell> symbol=RGDX
Parameter set.
All parameters bound. Beginning trading.
So the key question is: what module accepts a list of typed parameters and binds them into an object with automatic type conversion? For instance `amount_to_spend` gets set to a float while `symbol` gets set to a string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment