Skip to content

Instantly share code, notes, and snippets.

@postylem
Last active January 16, 2021 15:03
Show Gist options
  • Save postylem/6200414 to your computer and use it in GitHub Desktop.
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…
print (lambda x: x + str((x,)))('print (lambda x: x + str((x,)))',)
@bsmagic
Copy link

bsmagic commented Jan 15, 2021

TypeError: 'NoneType' object is not callable

Platform

python 3.8

@postylem
Copy link
Author

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