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 enough information for us to act on.

We need (at least) an example of a program that you want to modify.

From that we /might /be able to tell what you mean by "print" and "all strings".

I can hear you now "what's the matter with these guys - what part of print and strings do they not understand?".

Humor us. It is not a lack of understanding. "print and strings" have(to me) multiple meanings.

Currently we are guessing, as Alan has done, and we may be way off the mark. Guessing takes extra time and energy.

Having said that I will offer an alternative guess: assuming you are using Python 3 and you are using the built-in print function to "print strings", then you could redefine print by ading (at the top) (untested):

def print(something, **args): __builtins__.print(something.swapcase(), **args)

You can't do this with Python 2, as print is a statement and can't be redefined. You could alter the program - find all occurrences of "print" used as a statement, and replace them with a function call. So

print "asdf" would become swapprint("asdf")

and at the top you'd add (untested):

def swapprint(something): print something.swapcase()

--
Bob Gailer
919-636-4239
Chapel Hill NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to