Skip to content

Instantly share code, notes, and snippets.

@localredhead
Created May 28, 2012 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save localredhead/2817802 to your computer and use it in GitHub Desktop.
Save localredhead/2817802 to your computer and use it in GitHub Desktop.
Python quine(not quite)
def counted_quine():
"""This function has been quined 0 times"""
copy=[
"def counted_quine():",
"This function has been quined 0 times",
"copy=[",
"print(copy[0])",
"for i in range(1,2):",
" print(" " + chr(34)*3 copy[i].replace(''.join(i for i in counted_quine.__doc__ if i.isdigit()), str(int(''.join(i for i in counted_quine.__doc__ if i.isdigit()))++1)) + '\"\"\"')",
"print(\" \" + copy[2])",
"print(\" \"*2 + '\"' + copy[0] + '\"' + ',')",
"for i in range(1,2):",
" print(\" \"*2 + '\"' + copy[i].replace(''.join(i for i in counted_quine.__doc__ if i.isdigit()), str(int(''.join(i for i in counted_quine.__doc__ if i.isdigit()))++1)) + '\"' + ',')",
"for i in range(2, len(copy)-1):",
" print(\" \"*2 + '\"' + copy[i] + '\"' + ',')",
"print(\" \" + ' ]')",
"for i in range(3, len(copy)-1):",
" print(\" \" + copy[i])",
"print(copy[len(copy)-1])",
"counted_quine()"
]
print(copy[0])
for i in range(1,2):
print(chr(34)+' '*4+chr(34)+chr(34)*3 + copy[i].replace(''.join(i for i in counted_quine.__doc__ if i.isdigit()), str(int(''.join(i for i in counted_quine.__doc__ if i.isdigit()))++1)) + chr(34)*3 )
print(" " + copy[2])
print(" "*2 + chr(34) + copy[0] + chr(34) + ',')
for i in range(1,2):
print(" "*2 + chr(34) + copy[i].replace(''.join(i for i in counted_quine.__doc__ if i.isdigit()), str(int(''.join(i for i in counted_quine.__doc__ if i.isdigit()))++1)) + chr(34) + ',')
for i in range(2, len(copy)-1):
print(" "*2 + chr(34) + copy[i] + chr(34) + ',')
print(" "*2 + chr(34) + copy[len(copy)-1] + chr(34))
print(" " + ' ]')
for i in range(3, len(copy)-1):
print(" " + copy[i])
print(copy[len(copy)-1])
counted_quine()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment