Mar-20-2019, 10:35 AM
(Mar-11-2019, 02:50 AM)ichabod801 Wrote:(Mar-11-2019, 02:35 AM)MingyuanLuo Wrote: The default argument has None as default value.
Where are you getting that from? It's not in the documentation. The documentation describes the behavior of getattr as Yoriz did, and as you saw.
I saw and understand the documentation. But I saw this in builtins.py
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