Last active
January 16, 2021 15:03
-
-
Save postylem/6200414 to your computer and use it in GitHub Desktop.
This is the simplest model of a quine (a program that prints itself) I could think of in English:
«print this followed by itself in quotes: "print this followed by itself in quotes:"». My first try at making this in Python was a little less elegant:
«print (lambda x: x + '(' + repr(x) +')')("print (lambda x: x + '(' + repr(x) +')')")» Then I rea…
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 + str((x,)))('print (lambda x: x + str((x,)))',) |
yes, that code is for Python 2, @bsmagic. For Python 3, here's a try that's a little less elegant, but works:
print((lambda x: x + str((x,)) + ")")('print((lambda x: x + str((x,)) + ")")',))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Platform
python 3.8