[Python-ideas] Descouraging the implicit string concatenation
Steven D'Aprano
steve at pearwood.info
Wed Mar 14 09:26:17 EDT 2018
On Wed, Mar 14, 2018 at 01:43:53PM +0100, Søren Pilgård wrote:
[...]
> I have also experienced beginners asking why you can do `x = "abc"
> "def"` but not `a = "abc"; b = "def"; x = a b` and then you have to
> either explain them the differences between strings and string
> literals or just tell them to always use `+`.
If you tell them to "always use `+`", you are teaching them to be
cargo-cult coders who write code they don't understand for reasons they
don't know.
Life is too short to learn *everything*, I know that, and I've certainly
copied lots of code I don't understand (and hoped I'd never need to
debug it!). If that makes me a cargo-cult coder too, so be it.
But never over something as simple as the difference between names a and
b, and string literals "abc", "def".
--
Steve
More information about the Python-ideas
mailing list