[Python-ideas] between block and function [was: Custom Code Folding: Standardized Rules and Syntax?]

Jim J. Jewett jimjjewett at gmail.com
Tue Jul 18 21:13:11 EDT 2017

There have been times when I wanted to group portions of a module,
class, or function.  Giving names to each of those groupings would be
useful, and would be appropriate for python-level changes.

That said, it would probably need more proof in the wild first, so the
first step would be getting support in an
editor (such as PyCharm), and the second would be
an informational PEP on how to standardize the
practice, like PEP 257 does for docstrings.

For these steps, you would probably have to use a comment or string
convention, such as #{{{ or ":(group X ", though I suppose an external
file (similar to the stub files for typing) is also possible.

If these take off enough that the line noise gets annoying, that will
prove the need, and getting support from python itself will be a lot

Example code

:group C
class C1:
    :group emulateFoo

    :group manageBar
    def xx(self, bar, name, val=None):
        :group setupBar
        :group actualXX

class C2:

:group D

More information about the Python-ideas mailing list