DEV Community

Discussion on: What simple things annoy you about your favourite programming languages?

Collapse
 
_bigblind profile image
Frederik 👨‍💻➡️🌐 Creemers • Edited

In Python:

"Hello" "World" == "HelloWorld"
Enter fullscreen mode Exit fullscreen mode

This leads to bugs when you're writing an array of strings. This happens to me especially often when writing Django settings.py files

INSTALLED_APPS = [
  "foo",
  "bar"
  "baz"
]
Enter fullscreen mode Exit fullscreen mode

This sets ÌNSTALLED_APPSto["foo", "barbaz"]`. I wish this would throw a SyntaxError.

Collapse
 
mortoray profile image
edA‑qa mort‑ora‑y

C and C++ both do such string concatenation as well, though I've always considered it a feature. Put in this form it definitely will lead to unintended defects.

I wonder why it's there, given PYthon has string concatenation with a simple +.

Collapse
 
tbodt profile image
tbodt • Edited

Because

"hello" +
"world"
Enter fullscreen mode Exit fullscreen mode

is a syntax error, since the + doesn't make python join the lines. You'd have to do

("hello" +
"world)
Enter fullscreen mode Exit fullscreen mode