I'm new to OOP and python and I was just wondering if what I'm doing is "allowed" in OOP and if what I'm doing has a name to it. I have a Queue class
all_postcodes = Queue()
. The queue class has a method size to see how many elements are in it.
class Queue:
def __init__(self):
self.__items=[]
def size(self):
return len(self.__items)
I also have another class that accepts a Queue instance.
class something:
def __init__(self,postcode):
self.postcode = postcode
self._original_matrix = numpy.zeros((self.postcode.size(), self.postcode.size())))
I am then calling the something class like this:
all_postcodes_matrix = something(all_postcodes)
Are you allowed to have instances from one class as an argument in another and use it's methods? If you are, is there a name to what I'm doing?