How to create a script that list itself ?

Dave Hansen iddw at hotmail.com
Mon Jan 9 14:43:03 EST 2006


On 9 Jan 2006 10:09:19 -0800 in comp.lang.python, "Patrick  Allaire"
<pallaire at gmail.com> wrote:

>How to create a script that list itself ?

Stealing from the old C chestnut:

s="s=%c%s%c;print s%%(34,s,34)";print s%(34,s,34)


>
>I would like to know, where is the script's code is stored once we
>start it. I know I can achieve that, using files :

Well, in the above, the script (or rather, the information necessary
to print the script) is actually stored in a string that is part of
the script...

Regards,
                                        -=Dave

-- 
Change is inevitable, progress is not.



More information about the Python-list mailing list