1

I've done something stupid in Python, in Jupyter notebook. I deleted the cell that had my functions in it, probably a couple of hours ago, and now I don't have them any more. However, I can still run them, so they are still loaded in the kernel.

Is there a way to find that loaded kernel somewhere so I could copy those functions back into my code?

Thanks!

I've looked on the internet for ideas but haven't found anything.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
Anna
  • 21
  • 3
  • Check this - https://stackoverflow.com/questions/427453/how-can-i-get-the-source-code-of-a-python-function – Tom Ron Dec 19 '22 at 15:30

1 Answers1

1

I found how to solve this. The .getsource does the work:

import inspect
lines = inspect.getsource(set_claims_rebates)
print(lines)
The Myth
  • 1,090
  • 1
  • 4
  • 16
Anna
  • 21
  • 3