Definite or indefinite article for non-singletons?

Cameron Simpson cs at cskk.id.au
Sat Jul 27 18:09:10 EDT 2019


On 28Jul2019 07:10, Chris Angelico <rosuav at gmail.com> wrote:
>When talking about indistinguishable objects, is it correct to talk
>about "the <x>" or "an <x>"?
>
>Example:
>
>def f(s):
>    """Frob a thing.
>
>    If s is an empty string, frobs all the things.
>    OR
>    If s is the empty string, frobs all the things.
>    """
>
>It's entirely possible that a Python implementation will optimize
>small strings and thus have exactly one empty string, but it's also
>entirely possible to have multiple indistinguishable empty strings.
>Grammatically, is it better to think of empty strings as an entire
>category of object, and you were passed one from that category ("an
>empty string"), or to think of zero-length instances of 'str' as being
>implementation details referring to the one and only Platonic "empty
>string"?

It depends. If the API _specifies_ that something is a singleton then 
I'd use its proper name (eg None or ClassName.SENTINEL or whatever) and 
use a definite article (eg "the queue is considered closed when the 
sentinel is received").

>Does it make a difference to usage if the object is mutable? For
>instance, would you say "the empty string" but "an empty set"?

If the implementation _may_ fold indistinguishable things together I'd 
speak to the case that it may not, and say "if the string is empty", 
which (a) sidesteps whether there's only one empty string instance and 
(b) talks about the criterion for the decision and not some 
implementation artifact.

Cheers,
Cameron Simpson <cs at cskk.id.au>



More information about the Python-list mailing list