Created
December 3, 2011 06:20
-
-
Save grodtron/1426274 to your computer and use it in GitHub Desktop.
A quick quine in python. The long one I wrote, the short one I found.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print (lambda x:x+repr((x,)))('print (lambda x:x+repr((x,)))',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = [] | |
c.append('c = []') | |
c.append('f = lambda k: "c.append(" + repr(k) + ")"') | |
c.append('print c[0]') | |
c.append('print f(c[0])') | |
c.append('for line in c[1:]:') | |
c.append(' print f(line)') | |
c.append('for line in c[1:]:') | |
c.append(' print line') | |
f = lambda k: "c.append(" + repr(k) + ")" | |
print c[0] | |
print f(c[0]) | |
for line in c[1:]: | |
print f(line) | |
for line in c[1:]: | |
print line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# re-execute the program's output a bunch of times and then write the result to a new file | |
python quine.py | python | python | python | python | python > quineoutput.py | |
# there should be no difference between the output and the original file! | |
echo "begin diff:" | |
diff quine.py quineoutput.py | |
echo "end diff" | |
# clean up | |
rm quineoutput.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
import sys;print(open(sys.argv[0],'r').read())