'Python region folding syntax
I know python does not formally support any built in regional code folding syntax. I do know that a few syntaxes exist out in the wild with conventions tied to specific editors and particular comment pairs.
I know of the python source code folding syntax recognized by VS Code which uses the #region
keyword
#region MY_CODE_REGION
...
#endregion
I came across another I don't recognize taken from some source over at
https://github.com/gitpython-developers/GitPython/blob/master/git/objects/tree.py#L96-L104
which used the following syntax
#{ MY_CODE_REGION
#} END MY_CODE_REGION
What other editor syntaxes exist for python? Is there a pending PEP open on the subject?
Solution 1:[1]
I think #%%
is another option for the syntax you are looking for. This is from the Spyder editor as the method for separating sections of code (and it is listed there as the "standard cell divider" syntax)
https://docs.spyder-ide.org/3/editor.html#defining-code-cells
there are also ways to convert this to and from a jupyter notebook
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |