Recovering your Python 3 code from its *.pyc

There aren't many ways to (attempt to) recover your source after you've made the classic mistake of typing rm <some file> in the Linux terminal.

That's what I did early this morning, when I should have been sleeping.

After looking into a few command line tools, I found that pycdc worked wonderfully for converting files __pycache__/*.pyc in the directory your Python source was located. I looked into bash tools like foremost, but it required a config file in /etc, and it's not straightforward/intuitive regarding how to locate Python scripts in memory (after all, it's just a text file, there aren't any file signatures; maybe just special characters like #! or """).

The only negative side effect was that all of my comments and annotations were gone, which is a small price to pay for getting most of my code back!