P
P
pshevnin2021-12-20 11:57:31
Python
pshevnin, 2021-12-20 11:57:31

What is the correct way to pass objects in python?

Good afternoon.
there are three .py files in my program
main, database, classes
database:

list_of_objects = []

def read():
    
    f = open('data.txt')
    pocet_bytu = int(f.readline())

    for a in range(pocet_bytu):
        
        byt1 = byt.Byt(f.readline()) #declaration of object with name
        byt1.is_a = f.readline()
        byt1.adresa = f.readline()
        byt1.majitel = f.readline()
       
        
       list_of_objects.append(byt1)


in the database file I read the data from the txt file and store it in list_of_objects
main:
if __name__ == '__main__':
    database.read()

    print(len(database.list_of_objects))
    print(bdatabase.list_of_objects[0].data_for_print())
    print(bdatabase.list_of_objects[0])

in main, I run the read method, and then I try to write out to the console what was considered and stored in list_of_objects, but only the address of the variable is displayed in the console. How can this be fixed?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kadabrov, 2021-12-20
@Kadabrov

start with this book "Learning Python" by Mark Lutz

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question