- My friend, John, and I went shopping.
- My friend John and I went shopping.
I believe we need to wrap our friend's name in commas (first sentence example), but wouldn't that make it three people?
The first example could be a use of parenthetical commas - the commas here act like parentheses (braces), so it's equivalent to
My friend (John) and I went shopping.
So there's still just you and John.
I think that most people would assume John was the friend however the commas were arranged, unless they had prior knowledge to suggest otherwise. eg
John and I waited for ages for my friend to turn up. Finally she did, and my friend, John, and I went shopping.
Here you assume there's three people, even though the commas are the same as in the initial example. Instead of parenthetical commas, we now interpret the commas as separating items on a list. The last comma is what's called an "oxford comma", and is a subject of some debate, which can be summarised as do we say
"a, b, c, d and e"
or do we say
"a, b, c, d, and e"
I believe the latter (with the additional comma) is generally preferred, as it avoids ambiguity in phrases like "I'd like to thank my parents, Ayn Rand and God"., in which it sounds like the speaker is the child of Ayn Rand and God, while they actually meant a list of things consisting of [the parents, Ayn Rand, God].
My friend John and I went shopping.
You do not need to wrap the friend's name in commas – unless that friend is your only friend. Generally when you are identifying something or someone, such as John, you do not need (and should not use) commas.
If the name further identifies the person or thing from an otherwise broader category (all the speakers friends) it is essential: don't separate it with commas.
If the name only provides a name for the person or thing, but the previous description has already homed all the way in on them or it, the identifier is inessential: go ahead and separate with commas.
The New York Times addressed this issue in 'The Most Comma Mistakes'.
The syntactical situation I’m talking about is identifier-name. The basic idea is that if the name (in the above example, “Jessie”) is the only thing in the world described by the identifier (“my oldest friend”), use a comma before the name (and after it as well, unless you’ve come to the end of the sentence). If not, don’t use any commas.
Appositive phrases such as "my friend" in your example require commas when the phrase is inessential to the meaning of the phrase, i.e., it can be removed without losing meaning.
My mother, Mary, took me to see the Spice Girls in concert.
'Mary' is inessential--assuming I have only one mother (not always the case I know), then "my mother" is enough to identify who I am speaking about.
In your example, however, one would assume you have multiple friends (I don't know, but you seem nice enough). So 'John' is essential to understanding your meaning. The correct punctuation is without commas, as in your second example.
My friend John and I went to the store.
If it were a necessary appositive:
My teacher, Mr. Brooks, and I went to the store (My teacher is Mr Brooks and the two of us went to the store)
then I can't think of a way to make this unambiguous using commas alone, as it matches the equally correct sentence meaning that Mr. Brooks, another person who is my teacher, and myself all went to the store.
Rules exist to serve the clear expression of ideas, and not the other way round. If the commas introduce ambiguity then don't use them. If you don't like disobeying the rule (mentioned in some other answers) about parenthetical commas for additional information, reword the sentence or use brackets or dashes.
But it's not much of a rule anyway. You might say "my dog, Rover, likes to chase cats" according to the rule, but if you've got another dog (Rex) that doesn't, the commas become incorrect as the name is important information. A rule that depends on how many dogs you have, or similar context should be treated as a guideline at best.
How many people are in the sentence “My friend, John, and I went shopping”?
The answer is either two or three, depending on grammatical ambiguity.
The ambiguity arises from the conflicting grammar of lists vs. appositive phrases that end up giving the same result. Qualifying that my friend is John ends up giving identical output to making an Oxford comma list including a third person known only as 'my friend'. Without context, it is impossible to know which may have been intended.
When in doubt, restructure the sentence.
My friend, John, and I went shopping.
I went shopping with my friend John.
If you can't tell if a sentence contains two people or three, then you can safely assume that other people also won't be sure, and may misunderstand you.
Similar things have ended up in court.
Have you considered the following interpretation?
"My friend" is in the vocative form, meaning the whole statement is being spoken to someone who is your friend, telling them that you and John went shopping.
In that case there are three people involved, of whom only two went shopping.