Thursday, March 25, 2010

A one line Python Quine

OK, Here's a one line Python program that prints its own source code:

s='s=%r;print s%%s';print s%s

This wikipedia article on Quines is a very good place to learn how these things work

1 comment:

  1. How does this work? I am familiar with the

    print "one %s three" % "two"

    use of the % sign, but how does this work with simply printing s%s at the end?

    ReplyDelete