[Tutor] String switch

Dave Angel d at davea.name
Tue Oct 11 06:45:57 CEST 2011

On 10/10/2011 08:56 PM, Christopher King wrote:
> Okay, there is a python file called target.py. In the same directory there
> is a file named main.py. You are the author of main.py. The code in main.py
> will write to target.py. Then the antivirus catches main.py and removes, but
> not the modification to target.py. Main.py can not create new files. What
> would Main.py have to write to target.py, so that its output is swapped
> case. It does not matter how this is achieved. I know that one way is to do
> a regex search for every string in the file and then write the text of the
> file, with swapcases after strings, back to the file. What is a more elegant
> way for this to be achieved.
I'll try once more, before giving up.  You want to put something at the 
head of target.py that has some effect on the running of that script.

Which is it you want,  "output is swapped case"?

Or do you want the equivalent of putting swapcase() after each literal 

You can't have it both ways, since swapping the case of literals does 
not affect all output.  And it affects things that are not output.



More information about the Tutor mailing list