Re: [Tutor] String switch

2011-10-10 Thread Dave Angel
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

Re: [Tutor] String switch

2011-10-10 Thread Steven D'Aprano
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 ca

Re: [Tutor] String switch

2011-10-10 Thread Christopher King
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. Wh

Re: [Tutor] String switch

2011-10-09 Thread Dave Angel
On 10/09/2011 11:27 AM, Christopher King wrote: I know the method of finding every string, and inserting a swapcase in to the code. Does anyone now a way just to insert code at the top though? P.S. I use python 2.* Would you consider answering the rest of my questions? Since this is obviousl

Re: [Tutor] String switch

2011-10-09 Thread Alan Gauld
On 09/10/11 16:27, Christopher King wrote: I know the method of finding every string, and inserting a swapcase in to the code. Does anyone now a way just to insert code at the top though? Inserting code at the top of the file is just like inserting any kind of text at the top of any kind of te

Re: [Tutor] String switch

2011-10-09 Thread Christopher King
I know the method of finding every string, and inserting a swapcase in to the code. Does anyone now a way just to insert code at the top though? P.S. I use python 2.* ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options:

Re: [Tutor] String switch

2011-10-08 Thread Dave Angel
On 10/08/2011 03:03 PM, Christopher King wrote: 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.__

Re: [Tutor] String switch

2011-10-08 Thread Christopher King
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() *--Modifi

Re: [Tutor] String switch

2011-10-06 Thread bob gailer
On 10/5/2011 5:51 PM, Christopher King wrote: There is a program that will open another program, write code at the top of the program. The code at the top will cause the program to print all strings afterwards in swap case. What you've told us so far may make total sense to you, but it is not

Re: [Tutor] String switch

2011-10-06 Thread Alan Gauld
On 05/10/11 22:51, Christopher King wrote: There is a program that will open another program, write code at the top of the program. The code at the top will cause the program to print all strings afterwards in swap case. If I understand this correctly you have mainprog.py and subprog.py. And y

Re: [Tutor] String switch

2011-10-05 Thread bob gailer
On 10/5/2011 5:51 PM, Christopher King wrote: There is a program that will open another program, write code at the top of the program. The code at the top will cause the program to print all strings afterwards in swap case. Please provide a sample program that you wish to modify. -- Bob Gail

Re: [Tutor] String switch

2011-10-05 Thread Christopher King
There is a program that will open another program, write code at the top of the program. The code at the top will cause the program to print all strings afterwards in swap case. ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription

Re: [Tutor] String switch

2011-10-04 Thread bob gailer
Please always reply-all so a copy goes to the list. I'm forwarding this one for you. Please answer ALL questions that we ask. You did not answer What do you mean by "all other strings"? On 10/4/2011 4:55 PM, Christopher King wrote: This is (to me) vague. What do you mean by "at the top"

Re: [Tutor] String switch

2011-10-03 Thread Alan Gauld
On 03/10/11 01:33, Christopher King wrote: Dear Tutors, I was wondering how one would make it so all the cases of all the strings in a python file where switched. I know that for individual strings, you can use .swapcase(), So just apply swapcase() to the whole file as a string: s = open(

Re: [Tutor] String switch

2011-10-02 Thread bob gailer
On 10/2/2011 8:33 PM, Christopher King wrote: Dear Tutors, I was wondering how one would make it so all the cases of all the strings in a python file where switched. I know that for individual strings, you can use .swapcase(), but I'm making a program to edit others, so it would be easier

[Tutor] String switch

2011-10-02 Thread Christopher King
Dear Tutors, I was wondering how one would make it so all the cases of all the strings in a python file where switched. I know that for individual strings, you can use .swapcase(), but I'm making a program to edit others, so it would be easier to just do something at the top that would switch a