assigning to nested variables

John Thingstad john.thingstad at
Thu Nov 22 19:17:50 CET 2001

I tried to create the followin callback function in Python 2.1

from __future__ import nested_scopes

    def ask(self, pattern):
        Ask if query sentence is true; return 0 otherwise 1."""
        cPattern = self.convertClause(pattern)

        found = 0
        def match(bindings): global found; found = 1; return 1
        self.backChainEach(cPattern, match)
        return found

The ide was to assign 1 to found if the match callback function was called.
However, found = 1 creates a new local variable found and ask's found variable remains zero.
Is there a way to assign 1 to ask's found?
 I read the documantation but found no refrerence to this.

More information about the Python-list mailing list