<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>RE: [Python-3000] AST access (WAS: Adaptation vs. Generic Functions)</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Talin wrote:<BR>
> What remains is a consise way to specify bound vs.<BR>
> unbound variables I would prefer not to have to<BR>
> restrict people to using a limited set of pre-declared<BR>
> undefined variables, i.e. X, Y, Z, etc.; plus I<BR>
> would want to be able to associate additional<BR>
> constraints with those unbound variables.<BR>
<BR>
In Dejavu I did that with a separate "kwargs" attribute on the Expression object. You can set the kwargs attribute and it will be used when the Expression is evaluated:<BR>
<BR>
>>> e = logic.Expression(lambda a, b, **kw: a + b + kw['c'])<BR>
>>> e.kwargs.update({'c': 16})<BR>
>>> e.evaluate(1, 8)<BR>
25<BR>
<BR>
The "evaluate" method is a synonym for __call__ as well, and you can override previously-bound kwargs during evaluation:<BR>
<BR>
>>> e(1, 8, c=256)<BR>
265<BR>
<BR>
<BR>
Robert Brewer<BR>
System Architect<BR>
Amor Ministries<BR>
fumanchu@amor.org</FONT>
</P>
</BODY>
</HTML>