
x = 5 y = 5 print (x+y) #prints 10 This is easy because everyone knows that + sign adds 2 values together. print(str(x)+str(y)) #prints 55 I understand that there are more then one way to do this but, the bottom line is, this is not logical. Tony+Maria is what we used to write when we were little children fallen in love, but once we grow up, we started to think (more or less) and write the following: Tony & Maria This is pretty much what i suggest. Add new COMBINE operator sign & that will combine what ever value there is into one printable line without need for converting or formatting it. Examples: x = ("I love") y = ("this idea ") z = ("posted on November ") a = 18 print (x & y & z & a) # prints I love this idea posted on November 18 As of right now, this could look like this: x = ("I love") y = ("this idea ") z = ("posted on November ") a = 18 print (x + y + z + str(a)) and thats not much difference to worry about. Problem comes when there are more different data types need to be added and combined together. This would make things allot easier for many people and make string handling easier also.

Imo `&` is not a suitable replacement for `+`. Semantically when I read "Tony & Maria" it looks closer to behaving like a Set.union ala`{"Tony"}.union({"Maria"})` where comparatively the addition (+) infix operator is there to facilitate concatenation, which is a very common operation and does not behave like Set.union.
Quoting the zen of Python here:
Explicit is better than implicit.
I dont think Python should start allowing implicit type casting on select operators for builtins at the risk of subtle gotchas for the newer programmers.
The popular solution for this is explicitly formatting a string: `f"{x}{y}{z}{a}"` or for the more functional programmers out there folding a map `"".join(map(str, (x, y, z, a))`

On Nov 18, 2019, at 06:02, tonycstech@gmail.com wrote:
Sure it is. You’re concatenating two strings, using the same operator used to concatenate two lists or two tuples. It’s only misleading because those two strings happen to be digits. If the operator were &, it would be far more misleading that 5&5 is 5 (everyone knows that & intersects two values, which means bitwise and for integers) but str(5)&str(5) was "55" rather than “5”. Because now, you’re using the same operator used to intersect two sets or two third-party bitfield objects etc., but using it to concatenate two strings.
Your argument is that + is simple enough that it’s the first thing little children think of, but it’s too complicated for Python developers to learn?
This is pretty much what i suggest. Add new COMBINE operator sign & that will combine what ever value there is into one printable line without need for converting or formatting it.
So you can’t use & on ints, sets, etc. anymore? Or would there be some magic where it only does the convert and concatenate for types that don’t define &? (That would be even more confusing.)
If you just want this for printing, why not just use separate arguments? print(x, y, z, a) The print function calls str on all of its arguments and prints them. By default it prints them with spaces in between (so you don’t need the awkward extra space before the close quote in your x, y, and z, which you missed at least one of in your examples), but if you don’t want that, you can use sep=''. In addition to being more flexible, and already working, it’s also shorter, and more readable (the commas don’t compete for attention with the things you’re actually trying to print the way the ampersands do).
Why? Every data type is converted to string in the same way: the str function. Every data type is also automatically handled by print. So it doesn’t matter how many different data types you throw in, it’s not going to get more complicated than integers.

OMG people, no one said its a replacement for + Its an addition. that does nothing but combining data. It does not perform any mathematical operations whats so ever. It simply puts things together regardless of their data type. (1.1 & 5 & "word") results in 1.15word That fact that you say "will be far more misleading" is because its fundamentally misleading and needs to be fixed. Look at autoit code, even monkeys understand that & combines and + does math.

On Tue, Nov 19, 2019 at 6:31 AM <tonycstech@gmail.com> wrote:
OMG people, no one said its a replacement for + Its an addition. that does nothing but combining data.
Except that you're asking it to do something extremely similar to what the + operator already does.
By "puts things together", you actually mean "converts to string and then concatenates". What will your hypothetical operator do with these? q = bytes(range(240, 256)) w = fractions.Fraction(22, 7) e = [1, 2, 34, 5, 6] r = socket.SOCK_STREAM t = lambda: 123 print(q & w & e & r & t) If this is simply going to format each one as a string and print them, then why not, as has been suggested, simply print each item? print(q, w, e, r, t) Or, if you need to put the result into a string rather than immediately print it, why not call str() or format() on each value and then join them?
Look at autoit code, even monkeys understand that & combines and + does math.
Well, fortunately for us, we're a lot smarter than monkeys, so we can understand that + does integer math, float math, decimal math, list concatenation, string concatenation, bytes concatenation, and a host of other things. ChrisA

Imo `&` is not a suitable replacement for `+`. Semantically when I read "Tony & Maria" it looks closer to behaving like a Set.union ala`{"Tony"}.union({"Maria"})` where comparatively the addition (+) infix operator is there to facilitate concatenation, which is a very common operation and does not behave like Set.union.
Quoting the zen of Python here:
Explicit is better than implicit.
I dont think Python should start allowing implicit type casting on select operators for builtins at the risk of subtle gotchas for the newer programmers.
The popular solution for this is explicitly formatting a string: `f"{x}{y}{z}{a}"` or for the more functional programmers out there folding a map `"".join(map(str, (x, y, z, a))`

On Nov 18, 2019, at 06:02, tonycstech@gmail.com wrote:
Sure it is. You’re concatenating two strings, using the same operator used to concatenate two lists or two tuples. It’s only misleading because those two strings happen to be digits. If the operator were &, it would be far more misleading that 5&5 is 5 (everyone knows that & intersects two values, which means bitwise and for integers) but str(5)&str(5) was "55" rather than “5”. Because now, you’re using the same operator used to intersect two sets or two third-party bitfield objects etc., but using it to concatenate two strings.
Your argument is that + is simple enough that it’s the first thing little children think of, but it’s too complicated for Python developers to learn?
This is pretty much what i suggest. Add new COMBINE operator sign & that will combine what ever value there is into one printable line without need for converting or formatting it.
So you can’t use & on ints, sets, etc. anymore? Or would there be some magic where it only does the convert and concatenate for types that don’t define &? (That would be even more confusing.)
If you just want this for printing, why not just use separate arguments? print(x, y, z, a) The print function calls str on all of its arguments and prints them. By default it prints them with spaces in between (so you don’t need the awkward extra space before the close quote in your x, y, and z, which you missed at least one of in your examples), but if you don’t want that, you can use sep=''. In addition to being more flexible, and already working, it’s also shorter, and more readable (the commas don’t compete for attention with the things you’re actually trying to print the way the ampersands do).
Why? Every data type is converted to string in the same way: the str function. Every data type is also automatically handled by print. So it doesn’t matter how many different data types you throw in, it’s not going to get more complicated than integers.

OMG people, no one said its a replacement for + Its an addition. that does nothing but combining data. It does not perform any mathematical operations whats so ever. It simply puts things together regardless of their data type. (1.1 & 5 & "word") results in 1.15word That fact that you say "will be far more misleading" is because its fundamentally misleading and needs to be fixed. Look at autoit code, even monkeys understand that & combines and + does math.

On Tue, Nov 19, 2019 at 6:31 AM <tonycstech@gmail.com> wrote:
OMG people, no one said its a replacement for + Its an addition. that does nothing but combining data.
Except that you're asking it to do something extremely similar to what the + operator already does.
By "puts things together", you actually mean "converts to string and then concatenates". What will your hypothetical operator do with these? q = bytes(range(240, 256)) w = fractions.Fraction(22, 7) e = [1, 2, 34, 5, 6] r = socket.SOCK_STREAM t = lambda: 123 print(q & w & e & r & t) If this is simply going to format each one as a string and print them, then why not, as has been suggested, simply print each item? print(q, w, e, r, t) Or, if you need to put the result into a string rather than immediately print it, why not call str() or format() on each value and then join them?
Look at autoit code, even monkeys understand that & combines and + does math.
Well, fortunately for us, we're a lot smarter than monkeys, so we can understand that + does integer math, float math, decimal math, list concatenation, string concatenation, bytes concatenation, and a host of other things. ChrisA
participants (6)
-
Anders Hovmöller
-
Andrew Barnert
-
C. Titus Brown
-
Chris Angelico
-
ivanov_chris@yahoo.com
-
tonycstech@gmail.com