3 ms·
> I for one feel that + is a very intuitive choice for concatenating strings and lists. Is there any other common operator you would recommend instead? Literal
by enriquto 8y ago
> I for one feel that + is a very intuitive choice for concatenating strings and lists. Is there any other common operator you would recommend instead?
Literally, any other operator would be better than addition. A space, a dot, a product, two dots, a minus sign, whatever. Anything except the visually commutative plus.
> Because I feel that using a less common one would harm beginner-friendliness significantly.
Usage of + for string concatenation is fairly new, probably invented by C++ (which, by the way, uses bit shift operators for output, so it is not really an example of sane language).
- tomtimtall 8y ago“A”+”B” what do you feel should happen? “A”*6 what do you feel should happen?
- enriquto 8y ago> “A”+”B” what do you feel should happen? Clearly, that should be undefined. You cannot sum two strings. Unless you are really deranged and you want it to be "C".
- a1369209993 8y ago"A"+"B" = Regex("A|B") = Regex("[AB]") # or maybe "A"+"B" !> [?]Error: cannot convert /A|B/ to type str "A"*6 !> TypeError: <str> * <int>