<div> I asked the Shedskin developers about this issue and they are currently adding support for __call__ . They recommend renaming the class Matcher __call__ method ,for example as next, and then explicitly call it on line 148 as </div>
<div>lookup_func.next(match).</div>
<div> I followed their suggestion and the Shedskin 0.7 Python to C++ compiler does not complain about the unbound identifier 'lookup_func' anymore.</div>
<div> I apologize for the cut and paste mangling. Is there a better method than copy-pasting for including 20 or more lines of python source code in the tutor posts? Thank you.</div>
<div> </div>
<div> def find_all_matches(self, word, k, lookup_func): <br> lev = self.levenshtein_automata(word, k).to_dfa()<br> match = lev.next_valid_string('\0') <br> while match: <br>
follow = lookup_func.test(match) ### line 148 ### <br> if not follow: <br> return <br> if match == follow: <br> yield match <br>
follow = follow + '\0' <br> match = lev.next_valid_string(follow) </div>
<div><br> class Matcher(object): <br> def __init__(self, l): <br> self.l = l <br> self.probes = 0 <br> def test(self, w): <br> self.probes += 1 <br> pos = bisect.bisect_left(self.l, w) <br>
if pos < len(self.l): <br> return self.l[pos] <br> else: <br> return None</div>
<div> </div>
<div> </div>