On 5/2/2015 6:29 PM, Cecil Westerhof wrote:
At the moment I define the test functionality in the following way:
Any automated testing is better than none. For idlelib, I use unittest.
For an individual project with specialized needs, I use a custom test
framework tuned to those needs.
else:
action = options[0][0]
if action == '--all':
do_all = True
elif action == '--factorial':
do_factorial = True
elif action == '--fibonacci':
do_fibonacci = True
elif action == '--happy':
do_happy = True
elif action == '--lucky':
do_lucky = True
else:
print >> sys.stderr, progname + ': Unhandled parameter ' +
action
sys.exit(1)
There is usually a way to factor out the duplication of repetitive code
like this. Often, a dict is somehow involved. I believe the following
is equivalent to the above.
else:
action = options[0][0]
try:
globals()['do_'+action[2:]] = True
except KeyError:
print >> sys.stderr, progname + ': Unhandled parameter ' + action
sys.exit(1)
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list