Idea: from database_api import update_*
Current: from database_api import update_success, update_failure, update_running, update_initialized
This could clean up some code bases by allowing users to regex match some functions when importing. Full Regex matching may be slightly difficult, as an MVP, support for asterisks (*) matching would go a long way.
In the above codeblock, this would import all functions which start with “update_” from the module database_api.
I am completely against the idea, the first quality of Python is clarity of code and doing stupidly complicated things to make The International Obfuscated Python Code simple is The Wrong Thing™ to do (compare with IOCCC, also python3 -c 'import this').
Second, what you show is glob pattern (see glob package in the standard library), not regexp.
This idea probably won’t get much support, as the existing import * syntax is already discouraged. Part of the appeal of using the from module import stuff, things syntax is that it explicitly lists each name being imported; this proposal wouldn’t provide that explicitness.
Note that it’s already possible to avoid having to list all the names just by using qualified names, importing under an alias if you want to reduce keystrokes:
Instead of filtering exported objects by names, a more modular approach is to adopt the pattern used by the asyncio package, where classes and functions are organized as sub-modules of the package, and all that the __init__.py of the package does is to star-import names from all the sub-modules and to re-export them by joining all their __all__ lists:
So that if one wants to “filter” all the transport protocols for example they can star-import them from the protocols sub-module:
from asyncio.protocols import *
You can similarly group your update_* functions into a sub-module named database_api.update instead.
Whereas I don’t think it would be a good fit for the language itself (for similar reasons for which from x import * is discouraged in production code), I believe something along these lines might be a nice addition to the Python REPL – not as a syntax extension per se, but a kind of… action shortcut?
(It could be triggered by a sequence such as import identifier suffixed, as proposed, with asterisk… Or perhaps it could be just an optional action, with a dedicated keyboard shortcut, made available when tab-completion generates multiple options?)