How to display document content in msgprint


If I need to display the contents of the document in msgprint, how I can do that?

For example:
I have this code:

for d in self.get(‘items’):

and I need to display the contents of the d or the contents of self.get(‘items’), as we display the dictionary or the list, how?

I tried belows (all of them) but it was giving me error:
frappe.msgprint(“d is {0}”.format(d))
frappe.msgprint(“d is {0}”.format(dict(d)))

I was think if possible to display it same as I can do for dictionary or list or any string, how?


There’s no built-in __str__() method, wich will display the content of a document defined on the document. You either need to define yours and monkey-patch onto the document before msgprinting or simply msgprint(str(document.attribute)) to look at the content of the attributes. You can get the list of attributes qith msgprint(str(doc.__dict__)).