Most of the Python frameworks have some functions and classes that are widely used. For example a 'log.debug' function will be used in almost all modules. It is inconvenient to write 'import log' every time. It would be useful to have a special place (a dict or a special module) where you can declare attributes that can be used everywhere without importing anything. Currently, the only way to do this is: >>> import __builtin__ >>> __builtin__.debug = log.debug However, I think that this shouldn't be the better solution. Using something like '__framework__' would be really better, in my opinion.
Please, don't do that! Why not using "from framework import debug"? Working example: "from logging import debug". I hate namespace polution and all global symbols.
Not being able to figure out where a name came from easily is worse than having to type out the import statement. This feature would negatively impact readability of Python source significantly.
I agree that this shouldn't be added to Python. At a minimum, it is clear that there is too much opposition to such a feature that the bug tracker is an inappropriate medium to discuss it. If you want to pursue this idea, discuss it on python-ideas, and, if this shows sufficient interest in the feature, write a PEP.
History
Date
User
Action
Args
2022-04-11 14:56:44
admin
set
github: 49332
2009-01-27 18:25:06
loewis
set
status: open -> closednosy: + loewisresolution: rejectedmessages: +