Simple introspection?

Fredrik Lundh fredrik at pythonware.com
Sat Feb 8 10:58:13 EST 2003


"Afanasiy" wrote:

> # Can I make parentfunction print 'child' in a non-literal fashion?
>
> class parent:
>   def parentfunction(self):
>     print 'Can I print "child" here?'
>
> class child(parent):
>   def test(self):
>     self.parentfunction()

class parent:
  def parentfunction(self):
    print self.__class__.__name__

class child(parent):
  def test(self):
    self.parentfunction()

</F>








More information about the Python-list mailing list