Dividing Python module into multiple regions

I recommend you have a look at PyDev. If you structure your Python code well it will be very useful to have a document outline and code folding. Unfortunately I don't think you can do arbitrary structures like #region C# (VS) or #pragma mark in C/C++/ObjC (Xcode/CDT).


With Python Tools for Visual Studio you can use:

#region My Block of Code
def f1():
    pass
def f2():
    pass
#endregion

Then you can fold the regions same way you do on C#.


Looks like PyCharm has it, see here: https://www.jetbrains.com/help/pycharm/2016.1/code-folding.html#using_folding_comments

For Python files, the following two styles are supported. You should not mix both of them in a single file.

#<editor-fold desc="Description">
...
#</editor-fold>

or

#region Description
...
#endregion

Visual Studio accepts "region" too