As per the title. If I have an ESP32 with some Python loaded, and have lost the source, can I retrieve it from the ESP32?
In most cases (that is, unless you have compiled/frozen the Python code), yes.
Depending on the exact environment you may be able to just retrieve the file via the usual file transfer tools.
Alternatively, you can just connect to the REPL (console) and read the file from the filesystem:
file = open("fileyouwanttoread", "r") file.read()
This will display the contents of the file. You can then just copy and paste, and voilà!
You can find more examples of reading and writing files in this tutorial.