[pygtk] getattr confusion
Greg Ewing
greg.ewing at canterbury.ac.nz
Fri Oct 26 08:49:47 WST 2007
Donn wrote:
> 3. return getattr(self, property.name)
>
> How does it differ from just
> using "return self.property.name"?
The getattr function uses the run-time value of
the given expression as the name of the attribute.
So, for example, if property.name has the value
"spam", then getattr(self, property.name) is
equivalent to self.spam.
--
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury, | Carpe post meridiem! |
Christchurch, New Zealand | (I'm not a morning person.) |
greg.ewing at canterbury.ac.nz +--------------------------------------+
More information about the pygtk
mailing list