Search code examples
pythonquine

What are quines? Any specific purpose to have them?


I came across this term - Quine (also called self-reproducing programs). Just wanted to know more on it. How does one write a quine and are they used anywhere or they are just an exercise for fun?

I've started with Python, and I might try writing one in Python. Any suggestions?


Solution

  • Quines are useless in a practical sense, but they're a great exercise to help you learn more about a language.

    Here's a very concise one in python:

    a='a=%r;print a%%a';print a%a