Ernesto García García wrote:
> Hi experts,
>
> I've built a class for parsing a user-defined list of files and matching
> lines with a user-defined list of regular expressions. It looks like this:
>
(snip code)
>
> But then, when I try to use my class using actions with "memory" it will
> fail:
>>How would you do this?
>
> def line_action(line, match_dictionary):
> global count # make it a module-global variable, not a function-local
> count = count + 1
>
>
OK, I had put it on the global block.
Thanks,
Ernesto
--
http://mail.python.org/mailman/listinfo/python-lis
Ernesto García García wrote:
> But then, when I try to use my class using actions with "memory" it will
> fail:
>
>
> import LineMatcher
>
> global count
> count = 0
>
> def line_action(line, match_dictionary):
>count = count + 1
>
> line_matcher = LineMatcher.LineMatcher()
> line_matcher.add
Hi experts,
I've built a class for parsing a user-defined list of files and matching
lines with a user-defined list of regular expressions. It looks like this:
import re
import glob
class LineMatcher:
""" Parses a list of text files, matching their lines with the given
regular expression