[Tutor] what is foo

Clay Shirky clay at ernie.webservepro.com
Fri Aug 15 14:55:33 EDT 2003


> hey ive been reading several books about python lately and the \y all 
> included foo. Can someone please tell me what it is. Thanks 

foo is jokingly called the "metasyntactic varaible" in some hacker
circles, which is a way of saying "its our version of thingie", as in
"hon, have you seen that thingie that keeps water from going down the
drain?"

A common problem in explaining programming is how to tell the user
when part of an example is supposed to be replaced by them. 

One way to do it is to make the name self-secriptive, as in 

  for your_variable_name_here in your_list_name_here:
	  your_function_name_here()

but that can get tedious, so by convention, a variety of placeholder
names have sprung up, such as foo, bar, blatz, quux, and
spam. Whenever one of these appears in an example, it means "replace
it with a real variable, so "for line in foo.txt" means "replace
foo.txt with the real name of your file."

foo and bar are the commonest metasyntactic variables, and seem to
be phonetic representations of FUBAR, military-speak for "Fucked Up
Beyond All Recognition."

-clay

ps. The marvellous hackers dictionary (no url, but you can google it), has
lots of this sort of lore, btw.




More information about the Tutor mailing list