[issue18217] Deprecate and remove gettext.install

Terry J. Reedy report at bugs.python.org
Fri Jun 21 20:21:38 CEST 2013


Terry J. Reedy added the comment:

The rationale for install is "For convenience, you want the _() function to be installed in Python’s builtins namespace, so it is easily accessible in all modules of your application." As David noted, this also make it easy to update _ in just one place when a new language is selected.

Alex disagrees and would like to break any code that uses install, which I thing is much code, by removing it. This would force writers to do something else that will be *much* more work and which might make code harder to read. We do not do this without much greater reason than Alex has given. I think this a bad deprecation proposal and should be rejected. I also think the idea should have been posted to python-ideas first.

I do think that this should become a doc issue to clarify the meaning and usage of install.

The link Alex gave was to NullTranslations.install. The module install function itself is at
http://hg.python.org/cpython/file/01da7bf11ca1/Lib/gettext.py#l424

The doc for install could be much improved to say what it actually does.

"Pass *domain*, *localedir*, fallback=True, and *codeset* to translation, which returns translation instance t. Pass *names* to t.install. The default install method, NullTranslations.install <link>, which is inherited by GNUTranslations <link>, installs t.gettext in builtins as _. See the description of translation and NullTranslations.install for the meaning of the parameters."
+ rationale quoted above

This expanded doc would make it clearer that one can write a custom subclass of NullTranslations with a custom .install method that would do something different, such as bind _ to a dynamic (indirect) gettext, whether in builtins or in a project module that is explicitly imported by every module that needs it.

The doc for NullTranslations.install needs the erroneous '()'s removed to make clear that the bindings are to bound methods and not the result of calls to bound methods. Ie, self.gettest() should be just self.gettext.

----------
nosy: +terry.reedy
type:  -> enhancement
versions: +Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18217>
_______________________________________


More information about the Python-bugs-list mailing list