[Tutor] String switch

Christopher King g.nius.ck at gmail.com
Sat Oct 8 21:03:33 CEST 2011


Okay, here's what I what to do
*--Target.py--*
print "Hello World"
*--Target.py Output--*
*Hello World*
*--Main.py--*
target=open("target.py", "r")
old=target.read()
target.close()
target=open("target.py", "w")
target.write('''
Str.__repr__ = Str.__repr__.swapcase()'''+old)
target.close()
*--Modified Target.py--*
Str.__repr__ = Str.__repr__.swapcase()
print "Hello World"
*--Modified Target.py Output--*
*hELLO wORLD*

The only problem is I don't think that "Str.__repr__ =
Str.__repr__.swapcase()" works. What should I use in its place to make the
above a reality.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111008/9952343c/attachment.html>


More information about the Tutor mailing list