On a number of occasions, I've come across questions and which have nothing to do with gender, but contain example code assuming binary gender. A question might ask
What's the pythonic way to designate unreachable code in python as in:
gender = readFromDB(...) # either 'm' or 'f'
if gender == 'm':
greeting = 'Mr.'
elif gender == 'f':
greeting = 'Ms.'
else:
# how to indicate this can't happen?
when something like this would be equally illustrative, but be uncontroversial:
accessLevel = readFromDB(...) # should be ENUM('USER', 'ADMIN')
if accessLevel == 'ADMIN':
showDebugInfo = True
elif accessLevel == 'USER':
showDebugInfo = False
else:
# how to indicate this can't happen?
Is it okay to make changes like this?
In the context of the question, this change has no bearing on the meaning. It reads from a database, it has an if/elif/else chain based on the result (which is supposed to be an enum), some code runs based on the values, the else branch should never be taken.
Bringing up gender when it's not relevant, and especially claiming in example code that it can only be one of two possible values, is "likely to offend". Identity documents with three or more gender options are widely accepted and available.
Per the code of conduct:
language likely to offend or alienate people based on race, gender, sexual orientation, or religion
Many such examples literally assert
that some people's genders do not exist.
I've seen previous discussions about editing old content, for example the campaign to rid Stack Overflow of bad cryptography code.
The general consensus is that if you can "fix" the answer without destroying it, do so.
If you don't see a problem with the use of gender as an example for a question that is not about gender, consider the following example in the context of a question such as "how can I ensure the value of a variable is one from a small list":
(I'm sorry that this is provocative, but it wouldn't illustrate the point otherwise)
if race not in ('white', 'black'):
raise ValueError(f'invalid value for race: `{race}`')
This is not a duplicate.
The previous question it was marked as duplicate based on asked whether it was okay to replace "dude" with "person". While "dude" could be considered to be not inclusive, I don't think it rises to the level of "likely to offend", whereas "there are only two genders" does.