Re:What’s New in Python 3.5
by inglor on Tuesday July 07, 2015 @02:09PM
(#9847095)
As a fellow numpy user - why? I would love having sugar for this, I use it all the time. Introducing a single operator to overload seems odd but it's definitely a pragmatic solution to making code more readable. What would you do instead?
[ Parent
| on HN ]
Re:What’s New in Python 3.5
by Sanddancer on Tuesday July 07, 2015 @02:27PM
(#9847223)
Personally, I'd have made it a diglyph of some sort, like :* or ^*, to make it obvious to someone looking at python math code for the first time that this is a multiplication operator. @ just leaves a weird taste here.
Re:What’s New in Python 3.5
by JoshTriplett on Tuesday July 07, 2015 @02:42PM
(#9847323)
Agreed; this needs an operator, but it doesn't need a single-character operator, and the operator should have had * in it.
The pros and cons of different operator possibilities are discussed extensively in the PEP that added the matrix multiplication operator.
Re:What’s New in Python 3.5
by KeytarHero on Tuesday July 07, 2015 @05:26PM
(#9848224)
I love the snark in that PEP:
> APL apparently used +.× , which by combining a multi-character token, confusing attribute-access-like . syntax, and a unicode character, ranks somewhere below U+2603 SNOWMAN on our candidate list.
and then later, one of the reasons @ is better than the alternatives:
> Whatever, we have to pick something.
Re:What’s New in Python 3.5
by mixmastamyk on Tuesday July 07, 2015 @06:08PM
(#9848435)
What about the & char?
& is the bitwise and operator.
Re:What’s New in Python 3.5
by mixmastamyk on Wednesday July 08, 2015 @12:30AM
(#9849818)
Yep, forgot thanks.
Re:What’s New in Python 3.5
by JoshTriplett on Tuesday July 07, 2015 @04:41PM
(#9847969)
Not particularly well, though. No actual explanation was given for rejecting ^(star), and :(star) wasn't even mentioned.
(Aside: HN really needs a better way to escape star inline in text.)
It sounded like there was a bit of general preference for a single-character operator, which is a sentiment I can get behind.
OCaml has
* for int multiplication and * . for float multiplication.
you cannot overload but you can define your own,
so people tend to do things like define *: for complex multiplication.