echoing input

Skip Montanaro skip at mojam.com
Sun Aug 29 23:02:01 EDT 1999


    >> Hi.  Is there a way to get Python to echo the contents of a script
    >> while it is being loaded?  I have a script called x.py that contains:

    Gerrit> #!/usr/bin/python
    Gerrit> """
    Gerrit> echo the contents of a script
    Gerrit> """

    Gerrit> import sys

    Gerrit> SCRIPT = sys.argv[0]	# no, it's something else... (find the full path of the
    Gerrit> 			# script

    Gerrit> SCRIPT_CONTENTS = open(SCRIPT).read()

    Gerrit> print SCRIPT_CONTENTS

    Gerrit> # EOF

I don't see the script being executed anywhere.  I think what the original
poster asked for was a mode similar to the Bourne shell's -x flag.

If you don't might a horrendous impact on performance, look at my trace
module (in http://www.musi-cal.com/~skip/python/).  If you set verbose mode, 
it will spit out lines as they are executed.

Skip Montanaro | http://www.mojam.com/
skip at mojam.com | http://www.musi-cal.com/~skip/
847-971-7098   | Python: Programming the way Guido indented...




More information about the Python-list mailing list