Skip to content

bpo-31503: Customize module.__dir__.#3610

Closed
codypiersall wants to merge 3 commits into
python:masterfrom
codypiersall:module-dir
Closed

bpo-31503: Customize module.__dir__.#3610
codypiersall wants to merge 3 commits into
python:masterfrom
codypiersall:module-dir

Conversation

@codypiersall

@codypiersall codypiersall commented Sep 16, 2017

Copy link
Copy Markdown

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 in some_module.__all__, if it is defined. This PR makes dir(some_module) basically return some_module.__all__, if it exists. Otherwise, the old behavior is maintained.

https://bugs.python.org/issue31503

Allow dir(module) to be informed by module.__all__, if it exists.
@the-knights-who-say-ni

Copy link
Copy Markdown

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!

@bitdancer

Copy link
Copy Markdown
Member

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.

@codypiersall codypiersall changed the title Customize module.__dir__. bpo-31503: Customize module.__dir__. Sep 18, 2017
@codypiersall

Copy link
Copy Markdown
Author

Looks like this feature (or a close enough feature) is getting implemented as part of PEP 562, so I'm closing this PR. Woohoo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants