http://mail.python.org/pipermail/tutor/2000-March/001266.html
python.org 的Dennis 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