I've written a launcher/boilerplate python script that handles common initialization tasks for some network simulations I'm running. I'm having it dynamically load other python scripts that house the actual test code to run (defined in classes) based on cmdline args, and passing helper functions into the test battery code classes via a dictionary of lambdas.
Just to give you an idea, this is how the helper functions are being called:
self.helpers['createQueue'](switch=s1, port=3, qid=1, slice=700)
self.helpers['modFlow'](
switch=s1, cmd='add', tableid=0,
match='eth_type=0x800,ip_src=10.0.0.1,ip_dst=10.0.0.3',
actions='nw_dec,output=3,queue=1'
)
Just to clarify, everything works. But I'm wondering if there's a more idiomatic way to approach this problem.
Calling the lambdas from the dictionary like this is a little hard to take in at first glance, and I'm really not convinced this approach is good coding practice.
Any thoughts would be appreciated. I'm picking up python as I go, so my knowledge of the language and practice is somewhat patchy at the moment.