Classes in Python
Wiebke Pätzold
wiebke.paetzold at mplusr.de
Mon Aug 4 06:53:54 EDT 2003
On Mon, 04 Aug 2003 12:30:11 +0200, Wiebke Pätzold
<wiebke.paetzold at mplusr.de> wrote:
>Hi all!
>
>Could somebody help me with a task?
>
>import sys
>import Mk4py
>import re
>
>db = Mk4py.storage("c:\\datafile.mk",1)
>vw = db.view("people")
>
>class PatternFilter:
> def _init_(self, pattern):
> self.pattern = re.compile(pattern)
>
> def _call_(self, row):
> try:
> nachname = row.Nachname
> except AttributeError:
> return 0
> return self.pattern.search(nachname)is not None
>
>vf = vw.filter(PatternFilter("Ge.*"))
>
>for r in vf:
> print vw[r.index].Nachname
>
>
>
>I wrote this program, but it returns nothing. I can't find the error.
>Can somebody help me?
>Can somebody tell me why the part: "class PatternFilter:" doesn't
>return the expressions it should return?
>
>Wiebke
It has to be something wrong with line:
vf = vw.filter(PatternFilter("Ge.*"))
More information about the Python-list
mailing list