How to catch exceptions elegantly in this situation?
Paul Rubin
http
Fri Oct 8 01:39:45 EDT 2004
More information about the Python-list mailing list
Fri Oct 8 01:39:45 EDT 2004
- Previous message (by thread): How to catch exceptions elegantly in this situation?
- Next message (by thread): How to catch exceptions elegantly in this situation?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
syed_saqib_ali at yahoo.com (Saqib Ali) writes: > - Alternatively I tought of writing a function 'myFunc' and passing in > the args as follows: (dict=myDict, key="D", expression="a / b / c"). I > figured within 'myFunc' I would do: myDict[key] = eval(expression) > .......... However that wouldn't work either because the eval would > fail since the variables will be out of context. > > Any Suggestions?? exprs = [("A", "a+b+c"), ("B", "a-b-c"), ("C", "a/b/c"), etc.] for a,e in expr: try: myDict[a] = eval(e) except ArithmeticError: # whatever
- Previous message (by thread): How to catch exceptions elegantly in this situation?
- Next message (by thread): How to catch exceptions elegantly in this situation?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list