Michael Sproul

A Python Quine

Written by Michael Sproul on February 6, 2014.

I stayed up ’till 2am once working on this self-replicating program in Python. It’s preserved here because of this.

#!/usr/bin/env python
x = """#!/usr/bin/env python
x = {0}
# These comments make up 40% of this quine.
print(x.format('"'*3 + x + '"'*3))"""
# These comments make up 40% of this quine.
print(x.format('"'*3 + x + '"'*3))

There are lots of ways to write a Quine (particularly in Python) - I opted for format strings.


Tagged: python, quine