[Tutor] Simple ROT-13 Script
Matthew Hoffman
matthewmhoffman at hotmail.com
Mon Feb 2 23:36:50 EST 2004
Hello all! I have been reading this list for a goodly amount of time and
have never felt worthy to submit a question until now.
I just wrote a quick one-off script and I would like your opinions on any
Python-isms. It's just a ROT-13 script (I got a Neal Stephenson book for
xmas). I would just like to entertain your thoughts about what I could have
done better, etc. Cheers! ~Matt
#! /usr/bin/python
encrypt = lambda s: chr(ord(s) + 13)
decrypt = lambda s: chr(ord(s) - 13)
s = 'guido'
r = map(encrypt, s)
t = map(decrypt, r)
>>>r
['t', '\x82', 'v', 'q', '|']
>>>t
['g', 'u', 'i', 'd', 'o']
_________________________________________________________________
Find high-speed net deals comparison-shop your local providers here.
https://broadband.msn.com
More information about the Tutor
mailing list