Print your own code.

Neil Schemenauer nascheme at ucalgary.ca
Sat Sep 18 23:21:54 EDT 1999


Gerrit Holl <gerrit.holl at pobox.com> wrote:
>I heard that it's possible to write a python script that prints
>it's own source... is that true? How?

That is an old trick.  I believe it can be done in almost any
language.  Here is one solution for Python:

v = 'v = %s ; print v[:3], `v`, v[7:]' ; print v[:3], `v`, v[7:]

The interesting part about these types of programs is that you
can add an arbitrary amount of code once it is working.  This is
similar to how computer viruses copy themselves.


    Neil

--
"The percentage of users running Windows NT Workstation 4.0 whose PCs stopped
working more than once a month was less than half that of Windows 95 users."
  -- microsoft.com/ntworkstation/overview/Reliability/Highest.asp




More information about the Python-list mailing list