echoing input
Gerrit Holl
gerrit.holl at pobox.com
Sun Aug 29 03:20:44 EDT 1999
On Sat, Aug 28, 1999 at 12:24:32PM -0400, Greg Wilson wrote:
> 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:
>
> # x.py
> a = (1, 2, 3)
> print a
>
> and I would like to see
>
> a = (1, 2, 3)
> print a
> (1, 2, 3)
>
> as the output from "python x.py".
>
#!/usr/bin/python
"""
echo the contents of a script
"""
import sys
SCRIPT = sys.argv[0] # no, it's something else... (find the full path of the
# script
SCRIPT_CONTENTS = open(SCRIPT).read()
print SCRIPT_CONTENTS
# EOF
Is it also possible without reading a file?
regards,
Gerrit.
More information about the Python-list
mailing list