Nifty little python program

Create a python script with the following contents, and call it, say, quine.py:

1
2
3
a = """a = %c%c%c%s%c%c%c
print a %% (34, 34, 34, a, 34, 34, 34)"""
print a % (34, 34, 34, a, 34, 34, 34)

Now run it. The output is the program itself!
For double the fun, try this at a command prompt:
python quine.py | python - | python - | python -
(ad nauseum)
Super Cool!

Leave a Reply

By submitting a comment here you grant this site a perpetual license to reproduce your words and name/web site in attribution.