Imagine I went on Twitter and made the incendiary statement that Python 3.9.5 has not improved in any way on Python 3.0.
Could you prove me wrong?
If so, how?
28
2
76
You’re unable to view this Tweet because this account owner limits who can view their Tweets. Learn more
Additionally, the dictionary union operator (PEP 584, added in 3.9) is just some really nice syntax sugar to have: `d1 | d2` is arguably much more intuitive than `{**d1, **d2}`
between | and := I feel like a lot of the stuff people are selling python 3 to me on are things that strike me as "perl shit". like originally 18 years ago i dumped perl for python because it didn't have all these super specific operators. why not d1.union(d2)
On one hand, I love how python implements operator overloading. On the other, I have to look up set operators *every time* and nobody can convince me they help readability
It's intuitive if you're used to the bitwise operators since those are set operations defined over a set of indexed bits. It's a more general interpretation of them.
It makes a lot more sense than / for joining paths and perhaps even the + operator for joining strings too.
For union, | makes sense. Difference is what, - (not looking it up, on principle); bitwise ^ makes sense for ints, but not for sets since you dont want it to be commutative. Is intersection & ? Thats make sense.
Python defines | as union, & as intersection, - as difference and ^ as symmetric difference.
a ^ b gives a set with the elements that are in one set or the other but not in both just as it does for bits.
>>> 0b1010 ^ 0b1100
6
>>> sum({0b0010, 0b1000} ^ {0b0100, 0b1000})
6
It makes sense as long as you think of the bitwise operators as being set operators with integers as sets of bits. They also define the comparison operators as sugar for subset/superset.
I have far more problem with using / for joining paths. I think set operators make sense.
In fact, I think having them as operators on sets is a lot more useful than using them as bitwise operators in Python. I can't recall needing bitwise operators in Python for anything other than a Project Euler puzzle or something along those lines. Regularly use with sets though.
You could convince me that Python would be better without & | and ^ as operators but I can't be convinced that it makes sense to define them more narrowly as only bitwise operators. Python only really has those because it takes a lot of inspiration from C for a lot of syntax.