Skip to content

Auto comment indented blocks when first line is commented #130681

@Unknownuserfrommars

Description

@Unknownuserfrommars

Feature or enhancement

Proposal:

Currently: Python does this

class A:
    def B():
        print("Whatever")

When we comment out class A: (line 1), executing it will cause an indentation error (at line 2)

But if we want to comment out a whole class / def / with block, we have to manually comment out EVERY LINE.
Hence, i propose that:
When we comments out the first line of class / def / with block, Python interpreter auto-ignores the blocks in it.
So:

class A:
    # Do something
# class B:
    def func(a):
        print(a)

In the code above, python auto ignores the B class. This could be useful for a big function that errors out but we don't know which line is the problem (and its hard to debug)

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions