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:
main.py:
The output I get is
classtodo.py:
1 2 3 4 5 6 7 |
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) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
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() |
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!