How does Python distinguish explicitly passed None as argument in built-ins
问题 I experimented with the next code: >>> f = object() # It's obvious behavior: >>> f.foo Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'object' object has no attribute 'foo' # However, the next one is surprising me! >>> getattr(f, 'foo') Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'object' object has no attribute 'foo' # And this one returns None as expected: >>> getattr(f, 'foo', None) Then I found this pseudo