Just a small quine

Gerson Kurz gerson.kurz at t-online.de
Fri Jun 8 13:22:03 EDT 2001


On Fri, 8 Jun 2001 18:27:58 +0200, Pieter Nagel <pieter at equinox.co.za>
wrote:

>Small? Here's a one-line quine:
>
>	s="s=%c%s%c; print s%%(34,s,34)"; print s%(34,s,34)
>

note about my first one: the stuff at the top defines a brainf*ck
interpreter, the stuff at the bottom creates sourcecode for the
interpreter and then calls it... but its still python ;)

here are two other quines I wrote while brewing up that one:

def r(x):x=list(x);x.reverse();return "".join(x)
s="""
s tnirp;]:05[)s(r+)01(rhc+'"'*3+s+'"'*3+]25:[)s(r=s
)x(nioj."" nruter;)(esrever.x;)x(tsil=x:)x(r fed
"""
s=r(s)[:52]+3*'"'+s+3*'"'+chr(10)+r(s)[50:];print s

and

s="""s="s="+3*'"'+s+3*'"'+chr(59)+s
print s""";s="s="+3*'"'+s+3*'"'+chr(59)+s
print s

both use the same basic idea so its kind of a downer once you see
whats happening. 




More information about the Python-list mailing list