I’m asking a question similar to this, but with python 2.7 instead. I know that I’m the same asker of the question, but the answer should be different. Here’s the link.
How to make a variable name without creating an array in C++?
I looked up Data Structures on the python website, but I have no idea what they’re talking about. Any help or guidance appreciated!
If you are looking for a structure that is similar to
std::mapin C++, you should usedict. It is a dictionary, that can have any hashable object as key (a string, a tuple, an integer). For example:As you can see this is more powerful than
std::map, because keys might have different types and values too.If you want to assign a class, you also can do this:
but maybe you are interested in having an instance of this class? This also is possible (on the same
dict):