Definition of "getattr" incorrectly lists "default" value.

Here is the header definition of "getattr". def getattr(object, name, default=None): # known special case of getattr """ 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 is returned when the attribute doesn't exist; without it, an exception is raised in that case. """ pass ----------- The way this is shown is that, if you do not provide a value to the parameter "default", then it defaults to the value "None". However, that is NOT what is happening. You specifically have to pass in "None" in order for "default" to have the value "None" as in: fly_method = getattr(duck, "fly", None) You only see the querk if you read the info instead of just looking at the header. You need to change it back to : getattr(object, name[, default]) -> value Thanks.
participants (1)
-
B. James Maher