On Sat, 15 Apr 2006 07:36:30 -0700, fatal.serpent wrote: > Thank you. Also this script is PublicDomain right?
Oh heavens, I never even thought about that... the world was a much better place when you actually needed to *claim copyright* rather than just have it apply automatically on every stupid little doodle or comment. I've heard from authorities I trust that under US law private citizens can't "not copyright" something you write, even if you want it to go into the Public Domain. I've also heard the opposite from experts I equally trust. So, let me say firstly that I wish the following code to be put into the public domain, and if there is any reason why it has not been, I hereby give everybody an unlimited, non-exclusive, transferable, free of all charges and royalties, licence to use the following code in any way they see fit, with no conditions attached except there is no warranty. You don't even have to credit me. If you try to make a warranty claim against me for this code, the licence is instantly revoked. There. It probably won't stand up in a court of law, but I promise not to sue if you promise the same. > Steven D'Aprano wrote: >> On Fri, 14 Apr 2006 16:59:13 -0700, fatalserpent wrote: >> >> > Here is the basic code (yes, I know its tiny). >> > >> > x = ['print "x =", x', 'for m in x: print m'] >> > print "x =", x >> > for m in x: print m >> > >> > I want to modify this so it will output to a file called 1. What I want >> > is to have that file direct its output to a file called 2 and 2 direct >> > to 3 and so on. Hopefully this will be an easy-to-answer question. THX >> > in advance. >> >> From the shell, you are probably doing something like this: >> >> $ python mymodule.py >> >> Change it to this: >> >> $ python mymodule.py > 2 >> $ python 2 > 3 >> $ python 3 > 4 >> >> and so on. >> >> Alternatively, you can do this: >> >> x = ['f = file("2", "w")', 'print >>f, "x =", x', >> 'for m in x: >>f, print m'] >> print >>f, "x =", x >> for m in x: print >>f, m >> >> I'll leave changing the file name from "2" to "3" etc. as an exercise for >> you. >> >> >> -- >> Steven. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list