Why is foo bar wrong




















Paul M. Wexelblat in The earliest PDP-1 Assembler used two characters for symbols 18 bit machine programmers always left a few words as patch space to fix problems. Jump to patch space, do new code, jump back That space conventionally was named FU: which stood for Fxxx Up, the place where you fixed Fxxx Ups. When spoken, it was known as FU space.

Later Assemblers e. Bruce B. Reynolds in I haven't been able to find any references to foo bar as "inverted foo signal" as suggested in RFC and elsewhere. Atomic Energy Commission. For example:. If you are trying to explain a concept where the important part is not what is being done printing meow or bark for example but on how it is being done then removing the parts that you are familiar help:.

Now you have to focus on what is really happening, you are no longer able to guess at what is going to happen. So, the short version is, that foo, bar, and the like, are used to stress concepts where the content doesn't really matter but the idea does. In technology, the word was probably originally propagated through system manuals by Digital Equipment Corporation in s and early s.

Another possibility is that foobar evolved from electronics, as an inverted foo signal. This is because if a digital signal is active low so a negative or zero-voltage condition represents a "1" then a horizontal bar is commonly placed over the signal label.

The terms' origins are not known with certainty, and several anecdotal theories have been advanced to identify them. Foobar may derive from the vulgar military acronym FUBAR, or it may have gained popularity due to the fact that it is pronounced the same. Basically the idea is to convey your code without as much extraneous information that could possibly get away from how the code works i. These are nonsense words that in most cases can be substituted with more relevant example words. The words "foo" and "bar" are frequently used in programming when someone can't think of a good example.

If "foo" and "bar" are derived from FUBAR, why is it they are used by so many professionals in instruction examples when the examples resemble nothing being f'd up beyond recognition? Sign up to join this community. The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more. What is the history of the use of "foo" and "bar" in source code examples?

Ask Question. Asked 13 years, 1 month ago. Active 8 years, 2 months ago. Viewed k times. Active Oldest Votes. Mark, The German Wikipedia de. Jim Ferrans: While FUBAR probably influenced the use of "bar" with "foo", there is strong evidence that "foo" by itself well predates WWII, with references at least back to the s, as your comment indicates.

It might be good to mention that in the body of your answer. Yes, foo definitely predates WWII. In fact, I've found an MIT newspaper piece from that tells us how common it was: "As an expletive, of course, "foo! Add a comment. I think it's the phonetic pronouncation of fubar. Repair or Recognition ;P — Anders. It's "recognition". See quote from Rick Atkinson's Day of Battle here: stackoverflow. Show 3 more comments. Here are a few common signatures: foo, bar, baz, quux, quuux, quuuux So you navigate to the folder, open it, and find four files:.

The unique thing about the Foobar challenge is that it finds you. The first mention of the Foobar challenge seems to have been this post on HackerNews from back in What on Earth is that? If you dig into this a bit you will find some other pretty interesting projects. Here are just a few that I came across:. If this article was helpful, tweet it. Learn to code for free. Get started. Satish Sharma 9, 6 6 gold badges 24 24 silver badges 50 50 bronze badges.

Vincent Duprez Vincent Duprez 3, 6 6 gold badges 31 31 silver badges 66 66 bronze badges. It is very wrong. It generates warnings, but the worst part is that you might, at some point, have a constant define 'bar', 'lorem ipsum' and imagine what might happen in that case.

As for performance drop, that's a deep topic. Add a comment. Active Oldest Votes. I recommend you do it. Improve this answer. Shankar Narayana Damodaran Shankar Narayana Damodaran 66k 43 43 gold badges 90 90 silver badges bronze badges.

If you have turned on your error displaying then you can find notices like Notice: Use of undefined constant bar - assumed 'bar' in [ More technical detail about this is available here. One way to avoid this issue is to maintain a reference to the exception object outside the scope of the except block so that it remains accessible. Incidentally, our Python Hiring Guide discusses a number of other important differences to be aware of when migrating code from Python 2 to Python 3.

A solution to this somewhat more advanced Python programming problem would be to use atexit. That way, when your program is finished executing when exiting normally, that is , your registered handlers are kicked off before the interpreter is shut down. With that understanding, a fix for the above mod. This implementation provides a clean and reliable way of calling any needed cleanup functionality upon normal program termination. Python is a powerful and flexible language with many mechanisms and paradigms that can greatly improve productivity.

Familiarizing oneself with the key nuances of Python, such as but by no means limited to the moderately advanced programming problems raised in this article, will help optimize use of the language while avoiding some of its more common errors.

Subscription implies consent to our privacy policy. Thank you! Check out your inbox to confirm your invite. Engineering All Blogs Icon Chevron. Filter by. View all results. Author Martin Chikilian. Martin is a full-stack engineer and has worked as a professional Python developer since Read the Spanish version of this article translated by Marisela Ordaz.

About Python Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Common Mistake 1: Misusing expressions as defaults for function arguments Python allows you to specify that a function argument is optional by providing a default value for it.

Why did foo2 bomb while foo1 ran fine? You might expect the following output: 0 2 4 6 8 But you actually get: 8 8 8 8 8 Surprise! Common Mistake 9: Failing to address differences between Python 2 and Python 3 Consider the following file foo.



0コメント

  • 1000 / 1000