classes (table)

Christopher Boomer (don't dash!) c-b-o-o-m-e-r at
Wed Aug 6 15:16:41 CEST 2003

>     def __call__(self, row):
>         try:
>             nachname = row.Nachname
>         except AttributeError:
>             return 0
>         return not None

You should probably start by rewriting your basic function as

def search_call (self, row, column):
    if not hasattr(row, column):
        return 0 # No such column
    nachname=getattr(row, column)
    return is not None

Now you can choose the column at will within the program.
(nachname is now a poor choice of variable name)

To restrict access to columns, restrict this function and provide as a
public function the following:

def __call__ (self, row):
    return search_call(row, 'Nachname')

Hope this helps.

Christopher Boomer.

More information about the Python-list mailing list