Issue 5082: Let frameworks to register attributes as builtins (original) (raw)

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:44 admin set github: 49332
2009-01-27 18:25:06 loewis set status: open -> closednosy: + loewisresolution: rejectedmessages: +
2009-01-27 17:10:37 exarkun set nosy: + exarkunmessages: +
2009-01-27 17:09:04 andrea.corbellini set messages: +
2009-01-27 16:55:39 vstinner set nosy: + vstinnermessages: +
2009-01-27 16:38:25 andrea.corbellini set type: enhancement
2009-01-27 16:38:07 andrea.corbellini create