Skip to content

Instantly share code, notes, and snippets.

@Zhangerr
Created July 31, 2013 18:34
Show Gist options
  • Save Zhangerr/6124798 to your computer and use it in GitHub Desktop.
Save Zhangerr/6124798 to your computer and use it in GitHub Desktop.
a simple little quine in python.
s = "s = {0}{1}{0};{2}print s.format(chr(34),s,chr(10))"
print s.format(chr(34),s,chr(10))
@Zhangerr
Copy link
Author

things to note when writing a quine:

  • any special char that needs escaping in strings (like quotes, newlines, etc) must be replaced in a format instead
  • you can't use those chars in the literal represenation in format or else they would have to be escaped in the string!
  • the most mind boggling thing is inserting the string in itself
  • python has this function called repr that probably rendered the need for ascii char codes to be void

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment