translating PHP to Python

Dave davidworley at gmail.com
Sun Feb 5 14:29:22 EST 2006


Farshid,

This is a great help, thanks.

The second point won't work, though, because by parent class I mean,
simply, the object that created the current object, *not* the class the
current class is based on.

So, for example:

class A(object):
    def __init__(self):
        self.thing = Thing()
        self.thing.meth()

    def do_stuff(self):
        print "Stuff"

class Thing(object):
    def meth(self):
        #now here's what I WANT
        self.parent.do_stuff(args)

Is there a built in way to do this in Python, or do I have to pass
"parent" when I init Thing?

Sorry if this is confusing. It confuses me, too. I should have been a
carpenter.

- Dave




More information about the Python-list mailing list