News for hackers. Stuff that matters.
Re:Python 3 Features by hk__2 on Sunday June 29, 2014 @09:01AM (#7961058)
> Feature 0: Matrix Multiplication

It’s not really a feature, it’s an operator that can be overloaded. That is, instead of using `mymodule.dot(a, b)`, you can use the much less readable `a @ b`.

> Feature 1: Advanced unpacking

> Refactor your functions

The given example is a bad refactoring, because it moves away the function’s self-documentation.

Re:Python 3 Features by fddr on Sunday June 29, 2014 @09:30AM (#7961121)
> It’s not really a feature, it’s an operator that can be overloaded. That is, instead of using `mymodule.dot(a, b)`, you can use the much less readable `a @ b`.

I disagree with you, and think it's definitely a feature. If you are doing scientific computing it can be much more readable to use infix overloaded operators. What is better, `np.dot(x.T(), np.dot(M, x))` or `x.T() @ M @ x`? I find the second much more readable.

I get it that operator overloading can be abused and lead to unreadable code, but in some use cases it is a godsend.

Re:Python 3 Features by hk__2 on Sunday June 29, 2014 @02:03PM (#7961864)
That’s true, but you already can overload other operators like __mul__ to have `x.T() * M * x`.
Re:Python 3 Features by dagw on Sunday June 29, 2014 @04:10PM (#7962223)
__mul__ has been used for elementwise multiplication in numerical python for the past 18 years or so. You can argue if it was a good choice or not, but it's a bit too entrenched to change now.
Re:Python 3 Features by mhd on Sunday June 29, 2014 @02:23PM (#7961932)
Yeah, I didn't get the refactoring either. Unless it's a jab at Perl.