免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1513 | 回复: 0
打印 上一主题 下一主题

Python Quines [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-10-17 07:06 |只看该作者 |倒序浏览

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
X
quine4b.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
附:

文件:
python-quine.rar
大小:
9KB
下载:
下载


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/8780/showart_185871.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP