How to create an attachment in Python

Hi!

If I generate a file on the server in Python, how can I store and attach this file to an existing document?

Is there any utility function for this in frappe?

Thanks!
DoCa