The task is to invent names for things

Avi Gross avigross at
Thu Oct 28 13:23:46 EDT 2021

Names can be taken too far as the same variable may have different
connotations in one place than another.

Say I am counting how many of something and incrementing variable HowMany as
I go along and initialized to zero. Then I want to test if I have any and
instead of:

	if (HowMany > 0)

I decide to be cute and depend on the truthiness of HowMany like:

	if (HowMany)

The latter is a tad hard to parse for some people and if it had been named
WeHaveAny then the code would sort of make sense:

	if (WeHaveAny)

Somewhere else in the code some other names might make sense and make the
program easier to read.

So, the obvious solution is to ask the language, like Python, to allow
variables that are synonyms. In languages with pointers, this can often be
done fairly easily. In some languages with some optimizations, it can be
dangerous as some copies of this kind can later be changed to an actual copy
when the underlying data changes.

So, since at the moment you might not be able to do this:

	HowMany = 0
	alias HowMany WeHaveAny

Then if this feature matters to you, you could cautiously write code that
declares a second variable and copies either the current value of the first
or a Boolean true/false.

I am sure many of us (meaning me) have often named a variable and later
reconsidered once we saw the role it plays in various parts of the program
and had to go back and change everything. As other have noted, it is not a
trivial task and really good names often end up being really long names
which are also a pain especially when other really long names start with the
same characters. Compilers don't care but humans reading the code may give

Worse, many times the code consists of longer combinations and trying to
keep within reasonable (printable) line lengths gets hard.

] =
] + TheOfficialCertifiedVoteCountOfThisRegion

-----Original Message-----
From: Python-list < at> On
Behalf Of Karsten Hilbert
Sent: Thursday, October 28, 2021 2:50 AM
Cc: python-list at
Subject: Aw: Re: The task is to invent names for things

> > I don't know. A mediocre name conveys at least some information, and 
> > that seems to be better than none. On the other hand it might be 
> > just enough to lead the reader astray which wouldn't happen with a 
> > non-sensical name.

I was thinking that a nonsensical name might lead readers to go beyond the
name when trying to understand code, and would prompt me to improve upon the
name upon reading my own code (and having acquired, likely, a better
understanding of the concept that's to be named).



More information about the Python-list mailing list