Python Quines
时间:2006-10-17 来源:linxh
Quines
A quine is a self-printing program
http://www.aims.ac.za/~mackay/python/quine/quine.html
Here is A good page about Quines by David Madore.
Quines are named after the American mathematician and logician Willard van Orman Quine.
Douglas R. Hofstadter coined the name in his book Godel, Escher, Bach.
the verb to quine (invented by Douglas R. Hofstadter) means "to write (a sentence fragment) a first time, and then to write it a second time, but with quotation marks around it" (for example, if we quine "say", we get "say 'say'"). Thus, if we quine "quine", we get "quine 'quine'", so that the sentence "quine 'quine'" is a quine...
In this directory are ten quines I wrote to help me learn python. (One or two of them (X) are not quines; they are deliberately broken for teaching purposes.)
Also, another 8 quines in python that I found on the internet
My quines quine.py - rather large and awkward, but quite clear X quine2.py - not a quine, but very close; uses def and exec quine3.py - uses def and exec X quine4.py - teaching aid quine4a.py - works Xquine4b.py quine4c.py - works quine5.py - uses def and exec; follows on from 4c quine6.py - uses two types of quotes quine7.py - uses def and exec; more compact quine8.py - more compact still quine10.py - compact, with intron quine11.py - all these use 3 types of quote and no slashes quine12.py - includes she-bang; clearly laid out. quine13b.py - uses lambda; a one-line quine X quine13a.py - educational example to clarify 13b. SE.py - does this one count? In emacs, under C-cC-c, the output matches exactly! |
Other people's Short1.py Short2.py Short3.py Short4.py SomeQuine.py SheBang.py Intuitive.py Neat.py Obfusc.py Natural Language (txt) |
Here are some python programs to illustrate the idea that programs are maps.
grandfather.py
-> writer.py
-> fibo_iter.py
附:
|