Re:Formatting code should be unnecessary
by maleldil on Monday September 08, 2025 @08:37AM
(#45167523)
Nitpick: this looks like Python. You don't need + to concatenate string literal. This is the type of thing a linter can catch.
[ Parent
| on HN ]
Re:Formatting code should be unnecessary
by layer8 on Monday September 08, 2025 @02:30PM
(#45171983)
It’s actually Java, where the “+” is necessary.
Re:Formatting code should be unnecessary
by Sohcahtoa82 on Monday September 08, 2025 @03:36PM
(#45172866)
IMO, implicit string concatenation is a bug, not a feature.
I once made a stupid mistake of having a list of directories to delete:
directories_to_delete = (
"/some/dir"
"/some/other/dir"
)
for dir in directories_to_delete:
shutil.rmtree(dir)
Can you spot the error? I somehow forgot the comma in the list. That meant that rather than creating a tuple of directories, I created a single string. So when the `for` loop ran, it iterated on individual characters of the string. What was the first character? "/" of course.I essentially did an `rm -rf /` because of the implicit concatenation.