translating PHP to Python

Farshid Lashkari flashkNO at SPAMgmail.com
Sun Feb 5 13:40:43 EST 2006


> Is there a simple way to get the current object's name? You would think
> __name__ would work, right? It doesn't.

className = item.__class__.__name__

> I'd like to avoid passing a reference to an object's parent in
> __init__, but is there a built in way in Python to say "You, Parent
> Object, do ...stuff!"

Use the super() function to access an attribute of a parent clas

class C(B):
   def meth(self, arg):
     super(C, self).meth(arg)

-Farshid



More information about the Python-list mailing list