'Would giving a list of objects to another class , not make this relation aggregation?

class A:
    def __init__(self, id, name ,age):
        self.id = id
        self.name = name
        self.age = age

    def get_id(self):
        return self.id

    def get_name(self):
        return self.name

    def get_age(self):
        return self.age


class B:
    def __init__(self, lst, file):
        self.lst = lst
        self.file = file

    def writefile(self):
        fileObj = open(self.file, 'w')
        write_string = ''
        for person in self.lst:
            for func in [person.get_id, person.get_name, person.get_age]:
                write_string += func() + '\t'
            write_string = write_string[:-1] + '\n'
        fileObj.write(write_string[:-1])
        fileObj.close() 
            


def main():
    file = 'sample.txt'

    def loadfile():
        try:
            filez = open(file, 'r')
        except FileNotFoundError:
            filez = open(file, 'w')
            filez.close()
            filez = open(file, 'r')
        lst = []
        for line in filez:
            id, name, age = line.split('\t')
            age = date.rstrip('\n')
            lst.append(A(id, name, age))
        return lst

    population = loadfile()
    call = B(population, file)

    def add():
        obj_A1 = A('1','bilal','29')
        obj_A3 = A('3','asda','54')
        population.append(obj_A1)
        population.append(obj_A3)
    add()

    def display():
        for i in population:
            if i.get_id() == '3':
                print('found')
    display()

    call.writefile()
                
main()

Im new to OOP. im trying to understand if giving a list of objects to class B would make any difference to its relation. The relation i hope here is aggregation between Class A and class B if im not wrong since im adding population list to class B ? ps. sorry for the long code.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source