By making use of the outline minor mode of Emacs, one can do Python code folding. However, it seems MOST of the available .emacs examples illustrating this are broken, as you’ll find if you try to use them on any Python code longer than three lines.
Here is a correct example, thanks to me and goof.