python extension problem (newbie)

Douglas du Boulay ddb at
Tue Jun 1 21:57:57 EDT 1999

Hi ,

I've been trying to write a python extension in C to interface to a
Fortran program
and a class wrapper for the extension using the following code loosely
adapted from Mark Lutz's Programming Python  stackmodule example.

Unfortunately whereas his example works fine, mine goes into a recursive
loop whenever an
instance is instantiated.  It seems that the __getattr__  method of the
wrapper class
cannot find the getattr method of the extension library  and defaults to
trying to call itself, infinitely

Having spent about 8 hours trying to figure out why, I still have no



import p2fgraspint

class Grasp:
    def __init__(self, start=None):
        self._base = start or p2fgraspint.Grasp()
        print "doing done"                  # which is never executed
    def __getattr__(self, name):
        print "called getattr"              # executed  endlessly
        return getattr( self._base , name)
    def __setattr__(self, name, value):
        return setattr(self._base, name, value)

>> file

>> file

#!/usr/bin/env python
import oograsp
x = oograsp.Grasp()

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list