For example:
>>> import os
>>> '__dict__' in dir(os)
False
But os.__dict__ shows there is a __dict__ attribute.
Because dir uses a specialized implementation for modules, which returns all the keys in the module's __dict__, and thus neglects to include the __dict__ attribute itself.
It is not clear from reading the source code whether this is intentional.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With