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: Reimporting this and str.translate()
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: duplicate
Dependencies: Superseder: "import this" is cached in sys.modules
View: 19499
Assigned To: Nosy List: Rosuav, eric.snow
Priority: normal Keywords: patch

Created on 2013-11-16 04:46 by Rosuav, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
this-translate.patch Rosuav, 2013-11-16 04:46 review
Messages (2)
msg203008 - (view) Author: Chris Angelico (Rosuav) * Date: 2013-11-16 04:46
In an interactive session, typing 'import this' a second time doesn't produce output (as the module's already imported). Peeking into the module shows a string and what looks like a translation dictionary, but doing the obvious thing:

>>> this.s.translate(this.d)

doesn't work, because str.translate() expects a dictionary that maps Unicode ordinals, not one-character strings.

Attached is a patch which makes Lib/this.py use s.translate() instead of the wordier comprehension. Dare I ask, is there any possible code that this change could break? :)
msg203009 - (view) Author: Eric Snow (eric.snow) * (Python committer) Date: 2013-11-16 04:56
The this module was actually the subject of a similar proposal recently: issue19499.  The same arguments there for leaving the module alone apply here.  (Amon other things, it's a neat little artifact: http://www.wefearchange.org/2010/06/import-this-and-zen-of-python.html.)
History
Date User Action Args
2022-04-11 14:57:53adminsetgithub: 63820
2013-11-16 04:56:17eric.snowsetstatus: open -> closed

superseder: "import this" is cached in sys.modules

nosy: + eric.snow
messages: + msg203009
resolution: duplicate
stage: resolved
2013-11-16 04:46:43Rosuavcreate