[pygtk] getattr confusion

Donn donn.ingle at gmail.com
Thu Oct 25 21:27:19 WST 2007


Hello, learning pyGTK slowly. 

I am following an article about creating a widget and I'm a little stuck on 
this code:
1. def do_get_property(self, property):
2.  if property.name in self.__gproperties__:
3.     return getattr(self, property.name)

Why, in line 3, do they choose to use getattr? How does it differ from just 
using "return self.property.name"?

/d
-- 
"Life results from the non-random survival of randomly varying replicators."
-- Richard Dawkins



More information about the pygtk mailing list