Best Coding Practices – Plurals When Naming List Variables


When you are naming variables that contain a list object using the plural form of what it represents is more straightforward and easy to read. Here are some insights on naming list variables.

For example, when you have a list of users and you’d want to iterate through it. You’d write something like this.

for user in users:

The for user in users is better than for user in user_list.

But sometimes you would come across unquantifiable nouns like news. In that case, you would have to use news_list.

But please do not, forever, for as long as the universe exists, use something like for news in News. This should be punished severely.

This post was first published on July 29, 2012.


Karthikeyan KC

Aeronautical engineer, dev, science fiction author, gamer, and an explorer. I am the creator of Geekswipe. I love writing about physics, aerospace, astronomy, and python. I created Swyde. Currently working on Arclind Mindspace.

Leave a Reply

Your email address will not be published. Required fields are marked *