Making the Zen of Python more useful

Joe Mason joe at notcharles.ca
Fri Apr 2 19:23:45 EST 2004


In article <c4kkja$l7r$1 at news-int.gatech.edu>, Andrew Henshaw wrote:
> In article <mailman.284.1080928147.20120.python-list at python.org>, 
> n3613 at klaff.org says...
>>
>>
>>from this import s
>>s.decode('rot13')
>>
> Thanks for the response.  Unfortunately, this still has the (generally 
> desired) behavior of the text being printed to stdout.  For the less general 
> case of using the text to feed some test code, I don't think that is best.  
> Unfortunately, I can't think of a way to accomplish both by simply modifying 
> the 'this' module (for future releases).  Adding another module would do it; 
> but, I was hoping someone could suggest a better way.

I don't see the problem with an extra module.  Seems to me that there
should be one module which makes the Zen of Python available to the
program, and another which has the behaviour of printing on import.

The given solutions wrap the one that does the printing, which is inside
out - the one which prints should call into the one which provides the
text, if they're being distributed together.

I'm assuming that providing and printing the Zen of Python is the
module's main purpose, BTW, since I'm not familiar with it.  What is the
'this' module, anyway?  It's a name that's pretty much impossible to
Google for...

Joe



More information about the Python-list mailing list