Assume I have a simple array like this:
A = [1, 2, 3]
I can append or pop an element simply by doing:
A.append(0)
A.pop(0)
But if I turn this into a numpy array:
A = np.array(A)
A.append(0)
We get the following error (I know you can append an element to a numpy array but it requires more work):
AttributeError: 'numpy.ndarray' object has no attribute 'append'
Because if we check their types we see that they belong to different classes (I want to say that they are different objects but I find this terminology confusing):
<class 'list'>
<class 'numpy.ndarray'>
So apparently I cannot use built-in functions (you would say methods) for an object that is created by another guy (for example you cannot use a list if you turn it into a NumPy array because it is not a list anymore)
Then my question is, is this really how it is supposed to be? I mean was this really intended when the object-oriented design was created or are these kinds of things fundamental design flaws?
x = "33", that is astrobject, of course, if I have another kind of object,y = 22, I can't use the same methods. This is a pretty fundamental concept of OOPnumpy.ndarrayobject. The list still exists independently of the new object. This is btw, @Samwise why I don't like the "turn water into an ice cube" analogy, because you aren't mutating an object into a different type of object, you are creating a completely new objectnumpy.ndarrayobjects don't define.appendand.pop. This isn't a flaw, it is a carefully considered design choice. So no, it is exactly lie theintvsstrcase