First time here? Check out the FAQ!
1

Obtain the pycharm style block comment.

In Wing, I want to obtain the pycharm style block comment, say, for the following code block snippet in a class:

def measure_strain(self) -> float:
    """Measures the average strain on bond lengths on both substructures."""
    bond_lengths = self.bond_lengths
    bottom_strain = []
    top_strain = []
    for (k1, b1) in bond_lengths.items():
        for k3, b3 in self.bbl.items():
            if (k3 == k1) or (k3[::-1] == k1):
                d = np.abs((b3 - b1)) / b1 * 100
                bottom_strain.append(d)
        for k3, b3 in self.tbl.items():
            if (k3 == k1) or (k3[::-1] == k1):
                d = np.abs((b3 - b1)) / b1 * 100
                top_strain.append(d)
    strain = np.average(bottom_strain) + np.average(top_strain)
    return strain

In wing, the result is as following with the # Indented PEP 8 Style Comment

# def measure_strain(self) -> float:
    # """Measures the average strain on bond lengths on both substructures."""
    # bond_lengths = self.bond_lengths
    # bottom_strain = []
    # top_strain = []
    # for (k1, b1) in bond_lengths.items():
        # for k3, b3 in self.bbl.items():
            # if (k3 == k1) or (k3[::-1] == k1):
                # d = np.abs((b3 - b1)) / b1 * 100
                # bottom_strain.append(d)
        # for k3, b3 in self.tbl.items():
            # if (k3 == k1) or (k3[::-1] == k1):
                # d = np.abs((b3 - b1)) / b1 * 100
                # top_strain.append(d)
    # strain = np.average(bottom_strain) + np.average(top_strain)
    # return strain

But I want to obtain the pycharm style block comment as follows:

# def measure_strain(self) -> float:
#     """Measures the average strain on bond lengths on both substructures."""
#     bond_lengths = self.bond_lengths
#     bottom_strain = []
#     top_strain = []
#     for (k1, b1) in bond_lengths.items():
#         for k3, b3 in self.bbl.items():
#             if (k3 == k1) or (k3[::-1] == k1):
#                 d = np.abs((b3 - b1)) / b1 * 100
#                 bottom_strain.append(d)
#         for k3, b3 in self.tbl.items():
#             if (k3 == k1) or (k3[::-1] == k1):
#                 d = np.abs((b3 - b1)) / b1 * 100
#                 top_strain.append(d)
#     strain = np.average(bottom_strain) + np.average(top_strain)
#     return strain
hongyi-zhao's avatar
547
hongyi-zhao
asked 2024-03-02 02:52:34 -0600
Wingware Support's avatar
4.2k
Wingware Support
updated 2024-03-06 07:20:55 -0600
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

3 Answers

0

"No. I don't want them always in "Column 0", instead, the comment symbol, aka, "#", is placed in the column where the actual indentation position of the code block is located, which is also the behavior of pycharm comment style."

Thanks again for this suggestion. This will be added in our next release by the "# Uniformly Indented PEP8 Style Comment" option for the Editor > Block Comment Style preference.

Wingware Support's avatar
4.2k
Wingware Support
answered 2024-03-06 07:17:46 -0600, updated 2024-03-06 07:20:33 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
1

For your information, you can see the following effect commented out by pycharm:

image description

hongyi-zhao's avatar
547
hongyi-zhao
answered 2024-03-02 08:14:25 -0600
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

Set the Editor > Block Comment Style preference to "# PEP 8 Style Comment in Column 0". The indented style is often easier if you're working near commented-out code a lot or moving it around, which I think is why the default in Wing is indented. I suspect the default also predates PEP8!

Wingware Support's avatar
4.2k
Wingware Support
answered 2024-03-02 07:09:57 -0600
edit flag offensive 0 remove flag delete link

Comments

No. I don't want them always in "Column 0", instead, the comment symbol, aka, "#", is placed in the column where the actual indentation position of the code block is located, which is also the behavior of pycharm comment style.

hongyi-zhao's avatar hongyi-zhao (2024-03-02 08:11:33 -0600) edit

That looks like a useful option. We'll try to implement it. Thanks!

Wingware Support's avatar Wingware Support (2024-03-02 14:23:22 -0600) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer