Skip to content

Instantly share code, notes, and snippets.

@postylem

postylem/onelinequine.py

Last active Jan 16, 2021
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@bsmagic bsmagic commented Jan 15, 2021

TypeError: 'NoneType' object is not callable

Platform

python 3.8

@postylem

This comment has been minimized.

Copy link
Owner Author

@postylem postylem commented Jan 16, 2021

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