0
How can I create an object with property and add to an object list using python?
I have a funtion that expects a return from a list of products, this return is used by other futions and do not want to change the type of return, so I’m trying to assemble the same object of type list.
The idea is to simply add an object to a list, but I’m having some mistakes every time I try something different.
As in the case below I have the error:
0:"'Object' Object has no attribute 'Urltermo'"
Right on the line produto.UrlTermo = termo.TermoDescricao
buscaproduto: list = []
produto: object = object()
produto.UrlTermo: str
produto.UrlTermo = termo.TermoDescricao
buscaproduto.append(produto)
Question: why not create the class
Produto
to use there?– Woss
@Woss, the funtion that calls this code does not expect a typed type, also do not know if I can make the append of a type to list and cause no problem later
– Marco Souza
In Python there is no "typed type". You can do it quietly.
– Woss