How can I get .py text documents to show up in recents?

Solution 1:

I think this may go back to this issue, about what Spotlight considers to be a 'Document'.

What does Spotlight consider to be a 'Document'?

In short: Spotlight may not consider .py files to be 'text documents' for its purposes, (and the default application for those files may be a factor), and you may need to build your own Smart Search Folder that includes the file types you want.

(You could exclude xml files, or limit the filepath, as well as the 'recent' time limit.)