I come from a Matlab background. In matlab I can create a class definition and then create an array of objects. I can easily dereference each object with an index. In addition, when I call a method from the object array (without an index), I have access to all the objects in the array. E.g, say that myNewClass has the properties .data and .text, it also has the method .clob. I can:
% init
a(1) = myNewClass;
a(2) = myNewClass;
a(1).data = [0;0;0];
a(2).data = [1;1;1];
So that now, if I call a.clob (not a(1).clob or a(2).clob), I can do something like
% this is a function inside the methods definition of my class definition
function clob(self)
% self here is my object array, "a", from above
for i=1:length(self)
% deref a single object
self(i).goClobYourself;
end
end
How do I do something like this in Python? Please note, I want my class to be an indexed collection, kind of like a list. But, I don't want my "class-list" to accept any class, just myNewClass. If I inherit from "list," will my class just be a "list" class with the attributes .data, .text, and the function .clob? Also note, I don't want a "list" that contains my objects, I want my objects to be list so that I can deref them from an index: a[1].clob() or a(1).clob() (?? or something like that). Or, I want to pass the whole array to self: a.clob() gives me access to the list. I may have the terminology a little cloudy.
Best regards