-2

I have some words in my [technical] text that begin with an underscore. Should I use "a" or "an" in front of them? For example, should it be a _TextIOWrapper or an _TextIOWrapper? If I ignore the underscore, the first alphabetic symbol in the word is a consonant, which warrants an "a." However, when one reads the text aloud, the word is pronounced as "underscore-TextIOWrapper," starts with a vowel, and needs an "an."

A real example from a real text:

In such a scenario, the object created and returned by the open() function, an _TextIOWrapper, acts as a generator.

P.S. As suggested by the commenters, the answer depends on whether the underscore is voiced or silent, with which I agree. Then the question is, what would be a common reading practice: to spell it out as "underscore-TextIOWrapper" or ignore it and just say "TextIOWrapper"?

DYZ
  • 99
  • 1
    As the question stands, both "io" (eye-oh) and "underscore" begin with vowels (and therefore require "an"). Perhaps a different example would be more useful. – Tevildo Feb 04 '24 at 00:10
  • @Tevildo Indeed. Fixed it. – DYZ Feb 04 '24 at 00:14
  • 1
    Is it actual writing, an actual text. Or is it listing this below a sentence? Your question is not clear. – Lambie Feb 04 '24 at 00:17
  • @Lambie Added a complete sentence as an example. – DYZ Feb 04 '24 at 00:25
  • Oh, I would not put an an there. If the thing is _TextIOWrapper. "It returns _TextIOWrapper". There is no need for a determiner in this case, in my opinion. If would need it if you said: It returns a Text Wrapper. – Lambie Feb 04 '24 at 00:33
  • @Lambie, Grammarly seems to be ok with a determiner, but I do not know to what extent I can trust it in such a special situation. – DYZ Feb 04 '24 at 00:38
  • 1
    Like all such duplicates as this, this one has nothing to do the writing, only with sound. Speak it aloud and the answer shall appear. – tchrist Feb 04 '24 at 00:43
  • 1
    Presumably _TextIOWrapper is a class and the open() function returns an object of this class. It may be clearer (though longer) to write "the open() function returns an object of the class _TextIOWrapper". My advice is to consult your appropriate style guide, or else look for similar passages to see what other writers in your field have done. – Peter Feb 04 '24 at 01:30
  • Consider how you would normally pronounce the identifier Text_IO_Wrapper, or even string_overload_method: notice that underscores in identifiers are for the most part nothing more than spaces in phrases to make them easier to read. That being said, there is also a tradition of distinguishing for example exit() from _exit() in speech. In some programming languages a leading underscore does something special, just like how a leading capital letter might. But would you really distinguish textIOWrapper from TextIOWRapper from TEXT_IO_WRAPPER in speech? I bet not. – tchrist Feb 04 '24 at 01:42
  • In such a scenario, the _TextIOWrapper object created and returned by the open() function acts as a generator. – Tinfoil Hat Feb 04 '24 at 03:00
  • Normally the underscore is used with variables, not with names of classes. A variable is not a "word". So if you have class Dog, you might write "Instantiate a Dog and assign the instance to variable _dog " – TimR Feb 04 '24 at 12:24
  • In programming, if the verb is active (see below for the verb return), there is no a/an: "The main function calls two functions: report_square and report_ratio. As report_square takes no parameters and returns void, we don't assign its result to a variable. Likewise, report_ratio returns void, so we don't save its return value, either. After each of these function calls, execution continues at the next statement. Then main returns a value of 0 (typically used to report success) to end the program. https://learn.microsoft.com/en-us/cpp/c-language/return-statement-c?view=msvc-170 – Lambie Feb 04 '24 at 14:34
  • cont'd: And: Then, to run the example code, enter C_return_statement.exe at the command prompt. The output of the example looks like this: ///The link provided to "already answered" or duplicate does not apply here.//Also, the return statement is frequently shown in a box after a colon. – Lambie Feb 04 '24 at 14:40
  • In general, functions in Python may also have side effects rather than just turning an input into an output. The print() function is a basic example of this: it returns None///no an or a. Writing about code is not like other writing and the answer you chose is wrong. – Lambie Feb 04 '24 at 20:51

1 Answers1

1

P.S. As suggested by the commenters, the answer depends on whether the underscore is voiced or silent, with which I agree. Then the question is, what would be a common reading practice: to spell it out as "underscore-TextIOWrapper" or ignore it and just say "TextIOWrapper"?

Since it is the case that Americans, generally, speak of “an herb,” while some Britons prefer “a herb” (The Cambridge Dictionary provides an audio sample of both here). What is written, generally (but not always), reflects the writer’s (editor’s) preferred pronunciation.

As the person writing the piece, perhaps, your choice of article could serve as a clue to guide the reader toward your preference. I’d avoid spelling out underscore-TextIOWrapper as unwieldy and inappropriate for something using the preformatted text style for code.

_TextIOWrapper is much cleaner than the alternatives. Using an may highlight the presence of the underscore, thereby amplifying its importance in the reference. The choice to use a may deemphasize the underscore, perhaps in favor of readability.


Grammarphobia contemplates the choice of article with herb: Do we say “an herb” or “a herb”?

Glaadrial
  • 224