How to create a script that list itself ?

Tim Roberts timr at probo.com
Thu Jan 12 01:13:59 EST 2006


Duncan Booth <duncan.booth at invalid.invalid> wrote:
>
>Dave Hansen wrote:
>
>> Stealing from the old C chestnut:
>> 
>> s="s=%c%s%c;print s%%(34,s,34)";print s%(34,s,34)
>
>Or a bit shorter:
>
>s='s=%s;print s%%`s`';print s%`s`

It was pointed out to me that the shortest Python program which produces
itself on stdout is:
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list