Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I automatically redefine user-defined expressions?

Dear all, I imported expressions from different worksheets using load_session() consecutively. Now the problem is that I used different notations in some of them, so in order to unify the notations, I created a dictionary with the equivalent expressions and would like to crawl through all user-defined expressions and redefine them by substituing with the dictionary. Minimal example:

load_session('ws1')
load_session('ws2')
ndict = {}
ndict[P_va] = P_wa
list_names = show_identifiers()
list_eqs = [i for i in list_names if i[0:3] == 'eq_']
for expr1 in list_eqs:
    eval(expr1) = eval(expr1).subs(ndict)

TypeError: eval() arg 1 must be a string or code object

Does anyone have an idea how to do this? Thanks a lot!