Variables names don't need their type

Waylon Walker - Apr 8 '20 - - Dev Community

So often I see a variables type() inside of its name and it hurts me a little inside. Tell me I'm right or prove me wrong below.

Examples

Pandas DataFrames are probably the worst offender that I see

# bad
sales_df = get_sales()

# good
sales = get_sales()
Enter fullscreen mode Exit fullscreen mode

Sometimes vanilla structures too!

# bad
items_list = ['sneakers', 'pencils', 'paper', ]

# good
items = ['sneakers', 'pencils', 'paper', ]
Enter fullscreen mode Exit fullscreen mode

Edge Cases?

It's so common when you need to get inside a data structure in a special way that itsn't provided by the library.... I am not exactly sure of a good way around it.

# bad ??
sales = get_sales()
sales_dict = sales.to_dict()

# good
🤷‍♀️
Enter fullscreen mode Exit fullscreen mode

Containers are plural

Always name your containers plural, so that naming while iterating is simple.

prices = {}
items = ['sneakers', 'pencils', 'paper', ]
for item in items:
   prices[item] = get_price(item)
Enter fullscreen mode Exit fullscreen mode

Before I start fights 🥊 in code review, am I inline here or just being pedantic?

👇 NOW DISCUSS

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .