extracting variables accessed and written from function / rule-based function calls

Daniel dalist0 at gmail.com
Tue Nov 2 10:57:12 EDT 2010


> >> You might be interested by the story of how AstraZeneca tackled that
> >> kind of problem in PyDrone:http://www.python.org/about/success/astra/
that is interesting! So it seems they store the values in a
dictionary.
For each value they associate a function that gets called when the
value is not available.
This function uses the same dictionary to access the other values,
which might trigger more evaluations.
I like this approach. Unfortunately in my case it would not work,
because I might have more than one rule associated with each function,
depending on which values are available. If the wrong rule gets called
which needs to call other (wrong) rules I could end up in a loop, even
though everything
could be computed in principle.
lets say a follows from b or c (r1, r2) , b follows from a or c (r3,
r4) and c is given. Using this approach I would end up in a loop of
rules r1 and r3 to compute a.
I don't see how this approach could be made to work the other way
round, each value could have a rule attached that, given the
availability of other dependencies computes the
dependent values. That seems complicated, because one rule would need
to be associated with several values.

One possibility I thought of was to write the rules as python
functions and use the ast module to extract all the variables that are
being referenced. In principle this should be
possible. Is there any library around that does that?


Dan




More information about the Python-list mailing list