GetAttr (object, name[, default]), value
Get A named attribute from an object; GetAttr (x, ' Y ') is equivalent to x.y.
When a default argument is given, it's returned when the attribute doesn ' t
Exist Without it, an exception was raised in the case.
The explanation is very abstract and tells me that this function acts as a
Object.name
Try it. GetAttr (Object,name) is indeed the same function as Object.name. This is the only way to handle the name as a variable.
The example in the book is a good illustration of how this function functions.
Factory mode can be easily implemented with GetAttr.
Example: A module supports printing in HTML, text, XML and other formats, and calls different functions to implement output in several formats, depending on the formate parameter passed in.
Importdef output (data, format="text"): " output_%s " % format"return output_function (data)
Return the object of this method can be used directly if you want to add a new format only need to write a new method function in the module when calling the output function, you can use a different format output
Reference link:http://www.cnblogs.com/pylemon/archive/2011/06/09/2076862.html
[GetAttr () function in]python