Carriage returns

Heres a really dumb question:
When i make requests in the playground, completions are nicely formatted with carriage returns etc.

When i do it through python, i just get a big ugly block of text.

Is there a way to include the formating when saving it out in python?

I think it has to do with \n vs \r\n