Search code examples
pythonpython-3.xpep8

PEP guide for dictionary keys in python


Is there a PEP guide to follow as convention for dictionary key style?

Particularly for using upper/lower case letters and multiple words(with space or underscore).

For example, is it a correct style to have a dictionary like this:

client_income = {"MrJimmy_doctor California":300}

I know that I can use dictionary within dictionary for storing these information, but this is just a made up example. Also, I know that there is no syntax error here, but I want to know the convention.


Solution

  • There are no conventions on how to name the keys in a dictionary, they can be really arbitrary and it really depends on your application or problem you're trying to solve.