eigentlich soll meine Applikation von mir was folgt mehr oder weniger automatisch berechnen, aber Nutzer sollen doch auch die Möglichkeit bekommen einen Sack voll Paramter per Hand an eine Funktion zu geben. So ein Haufen Paramter kann, je nach Fragestellung an das Programm rel. lang aussehen, z. B. so:
Code: Alles auswählen
{'A': {'phi': 8, 'psi': -6, 'dz': 4, 'dx': -1.0, 'dy': -5, 'theta': 2.0}, 'C': {'phi': 8, 'psi': 8, 'dz': 5, 'dx': 5, 'dy': -5, 'theta': 8}, 'B': {'phi': 0, 'psi': 6, 'dz': -5, 'dx': 5, 'dy': 5, 'theta': 8}, 'E': {'phi': 4, 'psi': 0, 'dz': 5, 'dx': 2, 'dy': 5, 'theta': 8}, 'D': {'phi': 8, 'psi': 8, 'dz': 5, 'dx': 4, 'dy': -4, 'theta': -2}, 'G': {'phi': 8, 'psi': 8, 'dz': 1, 'dx': 5, 'dy': -1.0, 'theta': 8}, 'F': {'phi': 0, 'psi': 8, 'dz': -5, 'dx': 5, 'dy': -2, 'theta': 8}, 'H': {'phi': 8, 'psi': 6, 'dz': 5, 'dx': 4, 'dy': 5, 'theta': 8}}
Code: Alles auswählen
if move:
# check at least whether move is a dict
if not isinstance(move, dict):
raise AssertionError("given parameter 'move' is no dictionary, see documentation for" +
" further details")
for chain, params in move.iteritems():
if not isinstance(params, dict):
raise AssertionError("entry for chain %s is no dictionary" % chain)
for param, value in params.iteritems():
if not isinstance(value, (float, int)):
raise AssertionError("entry for %s in chain %s is not number (float or int)" %
(param, chain))
Gruß,
Christian