bpo-31503: Customize module.__dir__.#3610
Conversation
Allow dir(module) to be informed by module.__all__, if it exists.
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
|
Thanks for wanting to improve Python. At a minimum you will need to open an issue on bugs.python.org to discuss this proposal. However, it has significant backward compatibility issues, so it is unlikely to be accepted in my opinion, even if others agreed it would be a good idea. |
|
Looks like this feature (or a close enough feature) is getting implemented as part of PEP 562, so I'm closing this PR. Woohoo! |
Allow dir(module) to be informed by module.all, if it exists.
dir(some_module)could provide a more useful result than it currently does. Python already provides a protocol for specifying a module's API:__all__.dir(some_module)would be more useful if it only returned what is insome_module.__all__, if it is defined. This PR makesdir(some_module)basically returnsome_module.__all__, if it exists. Otherwise, the old behavior is maintained.https://bugs.python.org/issue31503