Text Folding in Python

I was wondering if anyone knows of a way that you can use folding to hide large blocks of unrelated code without having to place it all within a class?

I have this large block of code and I would much prefer it if I could fold all of them down into a single line or at least smaller than they currently are without having to edit the actual code.
If anyone has any ideas or knows of any packages that can do this for me it would be greatly appreciated.