Questions tagged [metasyntactic-variable]

13 questions
669
votes
5 answers

What is the purpose of the single underscore "_" variable in Python?

What is the meaning of _ after for in this code? if tbh.bag: n = 0 for _ in tbh.bag.atom_set(): n += 1
alwbtc
  • 23,407
  • 50
  • 123
  • 177
68
votes
3 answers

Underscore _ as variable name in Python

Peter Norvig has an essay describing a program to solve sudoku puzzles, even the hardest ones, by combining deterministic logical operations and smart traversal of the possible solutions. The latter is done recursively; here's that function…
32
votes
2 answers

What is the origin of foo and bar?

Where did they come from and when were they first used?
700 Software
  • 77,509
  • 74
  • 213
  • 324
28
votes
10 answers

To foo bar, or not to foo bar: that is the question

This was something originally discussed during a presentation given by Charles Brian Quinn of the Big Nerd Ranch at acts_as_conference. He was discussing what he had learned from instructing a Ruby on Rails Bootcamp to many people both new to…
25
votes
5 answers

Python underscore as a function parameter

I have a python specific question. What does a single underscore _ as a parameter means? I have a function calling hexdump(_). The _ was never defined, so I guess it has some special value, I could not find a reference telling me what it means on…
Steve
  • 259
  • 1
  • 3
  • 3
9
votes
1 answer

Meaning of foo, bar, baz, etc

I've always wanted to know what the foo, bar, baz, etc... names mean. Several times I've found these terms in scientific articles. Furthermore this terminology in some way serves as a standard for other exemplifications. Does anyone know where these…
Alvaro Joao
  • 7,787
  • 9
  • 42
  • 70
3
votes
2 answers

Why set underscores equal to a function?

I've searched for an answer here and elsewhere online, but all topics deal with either iterating a table, metatables, or times when _,var1 = do_some_stuff() which are not the case here. This is just a non-realistic function, but containing examples…
Pwrcdr87
  • 835
  • 3
  • 11
  • 32
2
votes
1 answer

cocoaasyncsocket sending data >128bytes (google protocol buffers)

I'm using cocoaasyncsocket to send data Google Protocol Buffers (using http://code.google.com/p/metasyntactic/wiki/ProtocolBuffers) to a Java server. This is all fine BUT for messages (protoToSend) >128bytes I'm running into issues as the Java…
2
votes
3 answers

Javascript getVariableName

This is my first post. I'm trying to do some basic meta-programming with javascript, and I was wondering if there is a way of get the id of a particular object and with that id, access to the variable name, or get simply the variable name of a…
crsuarezf
  • 1,041
  • 2
  • 17
  • 31
2
votes
0 answers

Why Foo, Bar and Baz?

Just by mere curiosity and without any goal in life... I was wondering what is the origin and the meaning (if there is any) of "foo", "bar" and "baz" as generic identifiers used in many programming examples?
2
votes
4 answers

Metasyntactic variables: do you use something else than "foo", "bar" according to your mother tongue

In english, the variables foo and bar are very often used for simple examples, or for anonymous variables (see these three posts for more on these metasyntactic variables (1), (2), (3)) Usually, I often use titi, toto and huhu and it seems that I am…
ThibThib
  • 7,270
  • 3
  • 27
  • 36
0
votes
1 answer

Use _ to escape more than one value in a for loop

Say I have the following data structure: input = [(1,2,3,4,5), (1,2,3,4), (1,2,3)] In a for loop, I want to iterate over only the first three elements in each tuple element at a time without worrying about how big the tuple is. I know I can use _…
Nobilis
  • 6,592
  • 1
  • 28
  • 58
0
votes
2 answers

I have heard Foo a lot, what does it mean?

Call me a noob, 'cause I really am, but what does 'foo' mean? I have seen it a lot. but I don't know what it means. Could someone clarify? All help is appreciated.
Flarp
  • 129
  • 1
  • 10