lazy eval()

Clarence Gardner clarence at netlojix.com
Fri Dec 29 16:40:22 EST 2000


Thanks to /F and Emile van Sebille for their suggestions.  /F's solution
is not only simple and elegant, it appears to have minimal overhead
relative to an eval with known names.

Emile, I didn't mean to be cryptic, I was just omitting irrelevancies.
Here's a sample of the kind of expressions that are currently in use:
    nDollars['12h', 'R'].nEQ(0)
This retrieves the values from a datastream identified by 'nDollars' that
were stored within the last twelve hours, creates a list of the differences
between successive values, then counts the number of those differences
that are equal to zero.

The problem is, these expressions are entered into a database by end users,
and I currently require them to store also the definition of the datastreams
that the expression uses.  Yucky; hence, I want to do the binding of the
name to the datastream when the expression is evaluated.  That binding has
to be deferred because
  1) I don't know the datastreams that the expression uses, and
  2) I'm generalizing the thing a bit, and the binding will be more
     complicated, possibly involving several SQL queries.

[Sorry, this isn't a followup; the POS newsreader that comes with KDE
crashed the first time I tried to post this, and lost the whole ng for
me :( ]

Clarence Gardner
clarence at netlojix.com




More information about the Python-list mailing list