Style question -- plural of class name?

R

Roy Smith

FooEntry is a class. How would you describe a list of these in a
docstring?

"A list of FooEntries"

"A list of FooEntrys"

"A list of FooEntry's"

"A list of FooEntry instances"

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.
 
S

Skip Montanaro

This one:
"A list of FooEntry instances"

Besides the obvious spelling issues in the others, it's not
immediately clear if the list contains just FooEntry instances,
FooEntry classes (perhaps subclasses) or a mix of the two. #4 makes
it clear.

Skip
 
J

John Downs

FooEntry is a class. How would you describe a list of these in a
docstring?

"A list of FooEntries"

"A list of FooEntrys"

"A list of FooEntry's"

"A list of FooEntry instances"

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.

How about: "A list with elements of type FooEntry"? I also like the last
one: "A list of FooEntry instances".
 
D

Denis McMahon

FooEntry is a class. How would you describe a list of these in a
docstring?

"A list of FooEntries"

"A list of FooEntrys"

"A list of FooEntry's"

"A list of FooEntry instances"

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.

I wouldn't use an apostrophe for pluralisation.

The Normal pluralisation of FooEntry would be FooEntries. Who are you
expecting to read the docstring? English majors, grammar nazis, wikipedia
editors, programmers, or all 4?
 
D

Dennis Lee Bieber

FooEntry is a class. How would you describe a list of these in a
docstring?

"A list of FooEntries"

"A list of FooEntrys"

"A list of FooEntry's"

"A list of FooEntry instances"

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.

A Folly of FooEntry

<G>

(though if one wants to consider "a school of fish", let the class be
its own plural...)
 
S

Steven D'Aprano

FooEntry is a class. How would you describe a list of these in a
docstring?


Which language are you writing your docstrings in? Obey the normal rules
of spelling, grammar and punctuation for your language, which I assume is
English.

"A list of FooEntries"

Perfectly acceptable.

"A list of FooEntrys"

There is no standard variant or dialect of English (British English,
American English, etc.) that pluralises Entry as Entrys, so that would be
"absolutely not".

"A list of FooEntry's"

"Here come's an S! Quick, jam on an apostrophe!"

This is called the grocer's apostrophe, and is universally held in
contempt no matter what variant of English you write in. Don't do this.

The only acceptable use of an apostrophe to make a plural is if the thing
being pluralised is a single letter. E.g. one a, two a's.

"A list of FooEntry instances"

This is also acceptable, although a little wordy. Do you write "a list of
strings" or "a list of str instances"?

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.

No weirder (note spelling) than changing any other noun. Whether you
change "int" to "ints" or FooEntry" to "FooEntries", you're still
changing it. That's how you make it plural.
 
C

Chris Angelico

"A list of FooEntry's"

Only if you put another apostrophe in:

"A list of 'FooEntry's"

But the delimited style is almost never of use. I'd go for this only
if there were some sort of automated markup being applied - if the
word FooEntry were turned into a hyperlink or something.

ChrisA
 
S

Steven D'Aprano

This one:


Besides the obvious spelling issues in the others, it's not immediately
clear if the list contains just FooEntry instances, FooEntry classes
(perhaps subclasses) or a mix of the two. #4 makes it clear.


I don't think this is a real issue. There isn't normally any ambiguity
between instances and subclasses. When you read "a list of ints", do you
assume that the list looks like [int, MyInt, AnotherInt, FooInt] or do
you expect it to look like [2, 7, 6, 1]?

The normal interpretation of "one or more Foo" is that we're talking
about Foo *instances*, not subclasses of Foo. If that is not that case,
then the onus is on the author of the documentation to make it clear that
they are talking about subclasses.
 
C

Colin J. Williams

FooEntry is a class. How would you describe a list of these in a
docstring?

"A list of FooEntries" 0

"A list of FooEntrys" -1

"A list of FooEntry's" +1

"A list of FooEntry instances" No FooEntry is specified as a class.

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.

Colin W.
 
C

Cameron Simpson

| On Wed, 08 May 2013 16:20:48 -0400, Roy Smith wrote:
| > "A list of FooEntry's"
|
| "Here come's an S! Quick, jam on an apostrophe!"
|
| This is called the grocer's apostrophe, and is universally held in
| contempt no matter what variant of English you write in. Don't do this.
|
| The only acceptable use of an apostrophe to make a plural is if the thing
| being pluralised is a single letter. E.g. one a, two a's.

Frankly, not even then for me. I spell that "one A, two As".

| > "A list of FooEntry instances"
|
| This is also acceptable, although a little wordy. Do you write "a list of
| strings" or "a list of str instances"?

How about "a FooEntry list"?
 
T

Thomas Rachel

Am 09.05.2013 02:38 schrieb Colin J. Williams:
Go back to school. Both of you...

That is NOT the way to build a plural form...


Thomas
 
N

Neil Cerutti

I wouldn't use an apostrophe for pluralisation.

If there's no chance for confusion between a class named FooEntry
and another named FooEntries, then the first attempt seems best.
Pluralize a class name by following the usual rules, e.g.,
"strings" and "ints".
 
J

Jussi Piitulainen

Neil said:
If there's no chance for confusion between a class named FooEntry
and another named FooEntries, then the first attempt seems best.
Pluralize a class name by following the usual rules, e.g.,
"strings" and "ints".

Like "strings" would be "foo entries". Which might work well.

(I mean, isn't the class named "str"?)
 
N

Neil Cerutti

Like "strings" would be "foo entries". Which might work well.

(I mean, isn't the class named "str"?)

Yeah, that's not such a good Python example. I used it to replace
"chars" and felt good at the time. ;)
 
R

Robert Kern

FooEntry is a class. How would you describe a list of these in a
docstring?

"A list of FooEntries"

"A list of FooEntrys"

"A list of FooEntry's"

"A list of FooEntry instances"

The first one certainly sounds the best, but it seems wierd to change
the spelling of the class name to make it plural.

I'm using services like Github more and more to talk about code, so I have taken
to adopting its inline markup for `code` when referring to identifiers. Thus, I
will often write

A list of `FooEntry`s

But I don't mind

A list of FooEntries

Hopefully there isn't also a `FooEntries` class.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top