Dan Espen <[email protected]> writes:
> Lawrence D’Oliveiro <[email protected]> writes:
>> On Mon, 15 Dec 2025 12:57:57 +0000, mm0fmf wrote:
>>> On 14 Dec 2025 11:56:42 GMT, Stéphane CARPENTIER wrote:
>>>> My issues with python are:
>>>> - It's using indentations, so when I comment a block of code to see
>>>>   what happens, it breaks everything and I have to manage the
>>>>   indentations. I can't just comment/uncomment a block of code as I do
>>>>   with other programming languages.
>>> ''' and ''' are your friend
>>
>> Unless the block has triply-quoted strings inside it ...
>
> Then """ and """ are your better friends.

Why bother? If you want to comment out a block, you can do just that,
much the same as in any other language.

    $ cat t.py
    def f(x):
    #    while x < 10:
    #        print(x)
    #        x += 1
        print("done")

    f(3)
    $ python3 t.py
    done

If you prefer the comment markers to match the indentation of the whole
block, that works too:

    $ cat t.py
    def f(x):
        # while x < 10:
        #     print(x)
        #     x += 1
        print("done")

    f(3)
    $ python3 t.py
    done

Or perhaps you prefer the comment markets to follow the lines they’re
commenting out:

    $ cat t.py
    def f(x):
        # while x < 10:
            # print(x)
            # x += 1
        print("done")

    f(3)
    $ python3 t.py
    done

-- 
https://www.greenend.org.uk/rjk/
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to