8
hitko
6y

"Multiline strings can be used as block comments in Python." Except in some places, where your code will pretty much blow up without any errors, because instead of commenting out a portion of an array, you've just added one big string element. And there's no other way to make block comments. And after actually commenting out every single line, your version control won't know how to merge it anymore, because there are now 100 changed lines instead of 2.

Comments
  • 2
    I also hate the python block comments. That and the lack of Switch-Case.
  • 0
    @lucaspar you are doing it wrong....whats wrong with elif blocks?
    and multiline comments should not be inside a list. ffs, what were you trying to do? use it outside the list block.
  • 0
    @magicMirror sometimes we want different inputs to have the same effect in our code - let's say different error codes that share the same logging or fallback method. Switch-Case handles it gracefully by chaining these cases.

    Using elif there would be code repetition and it's harder to realize that all conditions are using the same variable.

    A better replacement would be a dictionary with lambda functions as values. Each lambda would be like one "case". We would just have to handle the "default" case separately by checking whether the key exists in the dictionary or not.
  • 0
    @magicMirror What if I have a bunch of options defined as a list, and I want to temporarily disable all options between X and Y? Removing them in a feature branch wouldn't work, because feat branches are removed upon merge, and it would be a pain in the ass to find an revert that exact change after 100+ commits, hence block comment. And if there are AB branches block comments merge beautify, even if A has some extra options between X and Y, whereas commenting out each line causes a merge conflict at best.
  • 2
    Block comments are racist and anti-diversity, didn't you know? 😅
  • 0
    @hitko that is... dumb? wierd? not the correct way to do things?
    Just a suggestion: refactor the code to add each item using append(), and comment those lines, if you really have to use comments.
Add Comment