What's the right term for this basic programming thingy? [Answer found!]

Sometimes I can get really pissed of at dictionaries.
They can explain words, but they can’t give you the right term for a certain definition. This is one of those times.
There is some sort of class, dictionary function in programming languages which allows you to create integers, strings etc. to store data of individual objects in later on.
Like for instance:

string Name
int Age

John.Name = "John Noob"
John.age = 69

Maria.Name = "Maria Newbie"
Maria.age = 21


print "My name is" Maria.Name,
print "I am" Maria.age "years old."

That’s not real code, but you get the point.

So what’s the right term?

Class attributes?

In c++ the term consisted of one word, I think.


It was called “structures”!
Hmmm… what’s structures in python?

Python does not have structures, not directly. But you can simulate them.

Can you imagine I found that one just before I saw your post?
Thanks for the link anyway!
Nothing I can’t handle :stuck_out_tongue:

I would just use dictionaries.

template = {“name”:"", “address”:"", “age”:0}

andy = template.copy()
andy[“name”] = “john”
andy[“address”] = “shanghai”
andy[“age”] = 45667

jack = template.copy()
jack[“name”] = “Tim”
jack[“address”] = “iceland”
jack[“age”] = -89

What you have to be careful of here though is the .copy() call only does a shallow copy so if you had another dictionary inside the template, you’d have to copy that explicitly.

Thanks, osxrules!
Yeah, dictionaries seem the better choice. I did some tests and they’re working like a charm. :smiley: