I have a class with todo's (text and id) and import that class in my main program where I want to print it.
classtodo.py:
classtodo.py:
class ToDo:
def __init__(self, todo_id, todo_text):
self.todo_id = todo_id
self.todo_text = todo_text
def __str__(self):
return "{}:{}".format(self.todo_id, self.todo_text)main.py:import classtodo
todos =[]
#Funktion ToDos Anlegen
def todos_new():
todo_id = 1
todo_text = "text1"
new = classtodo.ToDo(todo_id, todo_text)
todos.append(new)
def todos_print():
print(str(todos))
todos_new()
todos_print()The output I get is Output:[<classtodo.ToDo object at 0x1040611d0>] - any idea what I'm doing wrong? I actually want to get the id (1) and the text (text1). I use Python 3.7. Thanks!
