65

In a comment on a Stack Overflow answer to my question, somebody said that "it is a very 'batteries not included' approach":

it doesn't look like there's any easy way to make a strict RFC 4627-compliant parser using just the builtin modules. In principle you could write your own parser (perhaps using Lex/Yacc/Flex/Bison), but that's a very "batteries not included" approach (and I'm not even sure how those tools integrate with Python, if at all).

I searched its meaning but ended up finding that the phrase was the name of a movie and a book. I would like to know what it means in the context and how it is often used. Many Thanks.

  • 25
    It is just a metaphor (fairly common on Stack Overflow, in my experience) that means something is not an out-of-box solution, not ready-to-go, will require tweaking, and probably involves some degree of hassle. Henry's answer provides the correct etymology. I've used this before myself, and never considered that its meaning might not be obvious to non-native speakers! – Cody Gray - on strike Apr 17 '17 at 12:06
  • 3
    Of course, the existence of a movie and book by that name do make things a little more confusing. – Zibbobz Apr 17 '17 at 16:30
  • 4
    @CodyGray Related to "... is left as an exercise for the reader." – GalacticCowboy Apr 17 '17 at 17:44
  • 9
    Also related to "some assembly required", implying that the product requires the user to complete a (sometimes substantial) amount of work to make the product functional. – asgallant Apr 17 '17 at 18:08
  • 2
    This is not a generic metaphor, but a common Python software term. (I almost thought that quote had come from me, because I have written similar Python software answers on SO) – smci Apr 18 '17 at 10:01
  • besides diagnosis and management of mitochondrial disease, and the movie title, it may mean, amusement, delight, and entertainment ahead, but come prepared with some input from yourself - metaphorically speaking. – Marvin Apr 18 '17 at 17:38
  • @CodyGray I've checked with many other (non-native) friends. None of them knows the background and the meaning behind the metaphor. And what's worse, it is hard to find a clear definition by google. I think I should spend more time on SO to learn more native usages. – ichbinblau Apr 19 '17 at 02:19
  • @CodyGray I wonder if "out of box" might have the same property? – Hatshepsut Apr 19 '17 at 08:16
  • Incidentally, it's a great movie; one of my favourites when I was a kid. – daiscog Apr 19 '17 at 09:06
  • @ichbinblau Now I have real curiousity about where you and your polled friends are from. I, for one, am not an english native, I'm spanish, but since we had a similar expression in our TV commercials ("Pilas no incluidas"), I've never had any issue understanding this idiom :) – xDaizu Apr 19 '17 at 10:09
  • @xDaizu We rarely see "batteries not included" in our TV commercials. In fact, batteries are conventionally not included. The problem is that we don't know the metaphor even though we know each word. :) – ichbinblau Apr 20 '17 at 05:41

3 Answers3

117

"Batteries not included" is a message you might find on the packaging of an electrically powered toy. Essentially it means that you should not expect the toy to work straight out of the box, and that you have to provide an essential component yourself to power it, namely the batteries.

So in this metaphorical context, the comment seems to be suggesting Python's json module does not provide the parser you are looking for, and you might have to put in a significant amount of extra effort yourself to provide what is missing, so as to get the whole thing to work as you expect.

Henry
  • 20,183
  • 57
    In particular, Python advertises itself as "batteries included" thanks to its comprehensive standard library. There is even a chapter in the docs with that title. That paragraph even specifically calls out the json module as an example, the very module that the question is about. – Jörg W Mittag Apr 17 '17 at 12:23
  • 3
    @JörgWMittag - I suppose the whole situation with Python may seem ironic, but in this particular case (regarding json), I believe the Stack Overflow comment misrepresented the effort required. OP needs to write either zero or two additional lines of Python code to make it work for them. I will say that some other Python "batteries" are arguably on the skimpy side. Regardless, this answer certainly gets the English right and explains it well. – John Y Apr 17 '17 at 14:06
  • 1
    @JohnY Supplying your own batteries is not a lot of work, so "batteries not included" is a good metaphor when you only have to do a small amount of additional work. – Barmar Apr 17 '17 at 16:11
  • 7
    One other bit of context since this is ELL-- the "batteries not included" often leads to much disappointment when you find the package that should do what you want, then you find out that it is missing some essential components to make it work. Just as a child is disappointed when he gets his much desired toy, only to find out "batteries not included" means he has to wait until after Christmas when the stores open to buy batteries. (though this is less of a problem today with rechargeable toys, retailers pushing batteries at the checkout lanes, and many retailers having Christmas hours) – Johnny Apr 17 '17 at 18:01
  • 6
    @Barmar - If you want to look at it that way, you are missing the aspects of the metaphor which are relevant to the context in which it is used. In programming, the batteries you need may or may not exist at all. You might not be able to go to a store to buy them; you might have to build them yourself, which is why Henry (and the Stack Overflow commenter) brought up the "significant extra effort". In OP's case, if we want to stick with this metaphor, Python's library does have the battery they need, they just have to bend the contact slightly to be more snug to the battery terminal. – John Y Apr 17 '17 at 19:02
  • In addition to packaging, it's common in the disclaimer section of advertisements, especially for toys that require batteries.

    It's apparently a legal requirement to avoid liability, though I don't know whether it arises through case law, regulation, or statute. The specifics seem likely to vary by jurisdiction.

    One reference I did find:

    https://www.quora.com/Why-do-TV-commercials-use-stock-phrases-like-batteries-not-included-and-each-sold-separately-and-where-did-they-come-from

    The movie gets its name from a character that only speaks in quotes he picked up from television.

    – Daniel Fackrell Apr 18 '17 at 15:41
  • @Johnny I think it's also less of a problem these days because people have learned to stock up on batteries before Christmas. – daiscog Apr 19 '17 at 09:10
19

This is a reference to Python's batteries included philosophy.

The Python source distribution has long maintained the philosophy of "batteries included" -- having a rich and versatile standard library which is immediately available, without making the user download separate packages. This gives the Python language a head start in many projects.

The manual has a section with the same title but that's a poor explanation.

The original quote is much better understood in a "batteries included, this solution is not" way because what it suggests is not adding a battery, much rather powering it via a generator attached to a standing bike so to speak. In other words, the other upvoted answer might be correct in the general sense to explain the generic "batteries not included" phrase but it has nothing to do with the problem at hand.

In this case, it means you would be using the "raw" features of the language and not components already written by others. As another example, you can download a webpage by opening a socket to the relevant IP address port 80, create a request based on the HTTP standard and correctly interpret the response, follow redirect(s) etc. That's the "powered through your own sweat" solution. Or

import requests
requests.get('https://english.stackexchange.com/a/384948/8720')

would be a "batteries included" kind of solution (even if actually requests is not included in the standard library but it serves as a quick demo).

chx
  • 791
  • 1
    I like that this answer provides another perspective and more carefully addresses the specific instance that motivated OP. The example using a "battery" that doesn't come with the standard library is especially illuminating. If I had to pick one "right" answer, it would be the other one, in large part because it is the more accurate answer to the general question reflected in the subject line, and thus is probably more helpful to more people finding this question in a search. But nice job, and easily worth an upvote from me. – John Y Apr 19 '17 at 13:28
  • 2
    The term "batteries included" has also spread from Python to other projects. The OCaml Batteries Included documentation (scroll to the bottom of the page) attributes their use of the term back to Python, and also mentions a similar project for Haskell. – DaoWen Apr 19 '17 at 16:48
2

The saying, as I've often seen it used is, describes something that doesn't include everything it needs to function. Much like its usage on toy or other electronics packaging, the item (the toy or such) requires you to create or acquire something (i.e. batteries), because that sub-component is distributed separately.