[Zope-CVS] CVS: Packages/pypes/pypes - interfaces.py:1.15
expression.py:1.7
Casey Duncan
casey at zope.com
Wed Mar 10 16:12:22 EST 2004
Update of /cvs-repository/Packages/pypes/pypes
In directory cvs.zope.org:/tmp/cvs-serv19259
Modified Files:
interfaces.py expression.py
Log Message:
Add freeNames() method to expressions
=== Packages/pypes/pypes/interfaces.py 1.14 => 1.15 ===
--- Packages/pypes/pypes/interfaces.py:1.14 Sun Mar 7 05:09:12 2004
+++ Packages/pypes/pypes/interfaces.py Wed Mar 10 16:12:21 2004
@@ -635,8 +635,14 @@
"""Introspectable, executable Python expression"""
def names():
- """Return a list of strings cooresponding to the names referenced in
+ """Return a set of strings cooresponding to the names referenced in
the expression"""
+
+ def freeNames(free_names=[]):
+ """Return a set of free variable names in the expression. Variables
+ are considered free if they appear in free_names, or are not found
+ in bound_names or Python builtins
+ """
def freeOperands(free_names=[]):
"""Return a list of Python ast node objects that coorespond to
=== Packages/pypes/pypes/expression.py 1.6 => 1.7 ===
--- Packages/pypes/pypes/expression.py:1.6 Mon Mar 1 01:36:15 2004
+++ Packages/pypes/pypes/expression.py Wed Mar 10 16:12:21 2004
@@ -58,6 +58,15 @@
_names.add(node.name)
self.names(node, _names)
return _names
+
+ def freeNames(self, free_names=[], _tree=None, _names=None):
+ """Return a list of names of free variable names in the expression.
+ Free variables are not in the expression's bound namespace or
+ builtins unless specified in free_names.
+ """
+ all_names = (
+ Set(self._bindings.keys() + dir(__builtin__)) - Set(free_names))
+ return self.names() - all_names
def freeOperands(self, free_names=[], _tree=None, _nodes=None):
"""Return a list of ast nodes cooresponding to top-level operands with
More information about the Zope-CVS
mailing list