Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@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. -
@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. -
hitko31456y@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.
-
@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.
Related Rants
"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.
rant
python
code
block comments