What is the meaning of "State"?

There is a paragraph that goes like this: “Tuples are called immutable data types because we can’t change their state after they’ve been created. Conversely, lists are mutable data types because their state can be changed after they’ve been created. The only way we could modify tuples, and immutable data types in general, is by recreating them. This is a list of all the mutable and immutable data types we’ve learned so far.”

In this context and in computer science in general, what does “state” refer to?

If I understand the question, my answer is this:

when reference is made to a change of state is that you are or have been able to modify the value in which it was to become another.

For example.

if we have the variable called a = 0 , its nature allows us to change its state to any value we need.

That does not happen in the tuples, as you point out the text to which you make reference these cannot change their state (to be modified).

I hope to have been able to help you.

A greeting.

A&E

Translated with www.DeepL.com/Translator (free version)

Thanks @Edelberth. I understand the concepts of immutable and mutable data types but I just wanted to get more insight on what “state” means. I’ve seen this word get thrown out a lot and I’m just curious.

1 Like

I think there is not a single interpretation of state, for example it appears in refactoring too: Design Patterns: State in Python. Similar to how theres multiple meanings of cardinality in database. In OOP, state can mean the __dict__ attribute of an instance or class. (the list of attributes attached to an object that you access using the same hex(id(object)) in memory.).

Then if you’re implementing the Markov Chain method, there are states there too.
Databases also have a state, that’s important to keep track of when multiple connections are writing and reading it. In Multiprocessing, shared memory objects also have state to handle.

This statement seems to be refering to changing the state of a. I don’t think this is accurate. We should be discussing the object, which is on the right hand side, which is an integer here that’s immutable.

1 Like