[Tutor] (no subject)
Daniel Yoo
dyoo@hkn.EECS.Berkeley.EDU
Fri, 14 Jul 2000 13:29:17 -0700 (PDT)
On Fri, 14 Jul 2000, Furmanek, Greg wrote:
> Interesting post, however ....
> It did not have anything to do with python!!
Well, it is pretty funny: it has to be the first time I've seen
_lowercase_ used to emphasize phrases.
>>> YOU CAN CHANGE THE DESIGN OF YOUR SITE AS MUCH AS YOU WANT with
>>> no extra charge! UNLIMITED TRAFFIC -- no extra charge!
I guess we could use their post and raise it's Python content by turning
it into a Python example. Hmmm... let's give it a shot.
###
import string
import sys
def reverseCaser(word):
if string.upper(word) == word:
return string.lower(word)
if string.lower(word) == word:
return string.upper(word)
return word
if __name__ == '__main__':
words = string.split(sys.stdin, ' ')
words = map(reverseCaser, words)
print words
###
Let's try it on this sample (because anything longer will cause my head to
explode.)
>>> you can change the design of your site as much as you want WITH
>>> NO EXTRA CHARGE! unlimited traffic -- NO EXTRA CHARGE!
Well, I admit, it's not much of an improvement. But even spams must yield
to Python. *grin*