为什么有那么多的例子程序使用foo和bar作为函数名?


http://mail.python.org/pipermail/tutor/2000-March/001266.html

python.orgDennis E. Hamilton 解释了原因:

Great question!

I can’t remember when I first saw foo and bar used in examples.  It was a
long time ago.  I have this sense that it was quite popular around MIT and
maybe even the DEC crowd and in the Multics community.  It is typically used
in composing file names in code examples about file processing.  There is
also a potential pun, from the days when connections to files had funny
names, like A01, C05, F00 (those are zeroes).

It is a mild joke.  There is an old US military acronym, FUBAR (other
military organizations will have their own versions).  In the context of
Python it means something like "Friendlied Up Beyond All Recognition".  Cf.
RTFM.  Once you’ve seen it, it becomes difficult not to use it.  The
continued use of it is for the same reason that it was used in the first
place:  "Where can I get some easy, meaningless file names to use in an
example?"  It’s easier than inventing new names.  And it is automatic.  And
there is tacit knowledge of it in the community, like recognizing a recuring
character in your favorite series of novels.

I’d be amazed if FOO and BAR are *not* mentioned in the Hackers Dictionary.

I’m grateful that you asked.  It reminds us of how much is taken for granted
that, for a neophyte, is not easily distinguished as having material or only
incidental importance.   With the wonderful international nature of
computing today, it is an important challenge for those of us who are
already "in the know" to provide clarity and simplicity.

– Dennis

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值