[Baypiggies] history of import this

Kelly Yancey kelly at nttmcl.com
Fri Jun 11 05:20:05 CEST 2010


On 6/10/2010 7:46 PM, Eric Walstad wrote:
> On Thu, Jun 10, 2010 at 7:01 PM, Keith Dart<keith at dartworks.biz>  wrote:
>> === On Thu, 06/10, akleider at sonic.net wrote: ===
>>> What syntax would one use to capture the string that gets printed
>>> when one
>>>>>> import this
>>> ????
>
> Why not just decode the rot13 string in the this module?
>
> def mra_bs_clguba():
>      """Ergheaf gur Mra bs Clguba"""
>      from this import s
>      d = {}
>      for c in (65, 97):
>          for i in range(26):
>              d[chr(i+c)] = chr((i+13) % 26 + c)
>      return "".join([d.get(c, c) for c in s])
>
> if __name__ == '__main__':
>      print(mra_bs_clguba())
>
>

That is what Asher's original post did, except that he utilized the 
ROT13 mapping that the this module already calculated and stored in the 
dictionary d.

 >>> import this
 >>> s = "".join([this.d.get(c, c) for c in this.s])

The problem with both, in my mind, is that both the "import this" line 
and the "from this import s" lines spam stdout.

Kelly


More information about the Baypiggies mailing list