This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Let frameworks to register attributes as builtins
Type: enhancement Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: andrea.corbellini, exarkun, loewis, vstinner
Priority: normal Keywords:

Created on 2009-01-27 16:38 by andrea.corbellini, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg80656 - (view) Author: Andrea Corbellini (andrea.corbellini) Date: 2009-01-27 16:38
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.
msg80657 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-01-27 16:55
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.
msg80658 - (view) Author: Andrea Corbellini (andrea.corbellini) Date: 2009-01-27 17:09
Well, writing every time 'from X import Y' looks to me uncomfortable.
But of course what I'm asking is not essential :-)
msg80659 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-01-27 17:10
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.
msg80666 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2009-01-27 18:25
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:44adminsetgithub: 49332
2009-01-27 18:25:06loewissetstatus: open -> closed
nosy: + loewis
resolution: rejected
messages: + msg80666
2009-01-27 17:10:37exarkunsetnosy: + exarkun
messages: + msg80659
2009-01-27 17:09:04andrea.corbellinisetmessages: + msg80658
2009-01-27 16:55:39vstinnersetnosy: + vstinner
messages: + msg80657
2009-01-27 16:38:25andrea.corbellinisettype: enhancement
2009-01-27 16:38:07andrea.corbellinicreate