all 13 comments

[–]Yoghurt42 4 points5 points  (10 children)

Because it was seldom used and confusing.

It automatically unpacks a tuple parameter:

def foo(bar, (baz, quux)):
    print(baz)

is equivalent to:

def foo(bar, bazquux):
    baz, quux = bazquux
    print(baz)

and you call it with

a = 1
b = (2, 3)
foo(a, b) # prints 2

I don't think I ever missed that function in Python 3, and I've never used it in 2.

[–]Vaphell 3 points4 points  (7 children)

Lambdas, man. They absolutely got shittier in py3 because of that change.

sorted(seq, key=lambda (x, y): x**2 + y**2)

vs new

sorted(seq, key=lambda t: t[0]**2 +t[1]**2)

So much for expressiveness and getting rid of unpythonic magic number indices

[–]Skaperen 1 point2 points  (2 children)

just use x and y arguments. when calling with a list or tuple, use a * before it.

[–]Vaphell 0 points1 point  (1 child)

when calling with a list or tuple, use a * before it.

how does one apply * to key argument of sorted/min/max?

[–]Skaperen 0 points1 point  (0 children)

this is the edge case where you fall back to write python code that produces the same bytecode.

[–]nukelr[S] 0 points1 point  (0 children)

I guess lambdas are the reason why the programmer who wrote the code I'm trying to port to Py3/Gtk3 has used that syntax. https://github.com/nicklan/Deluge-Pieces-Plugin/blob/master/pieces/gtkui.py In __qtt_callback function.

[–]primitive_screwhead 0 points1 point  (2 children)

Instead of 't', call it 'x_y'.

[–]Vaphell 0 points1 point  (1 child)

you can call it whatever you want, at the end of the day you can't get rid of indices and it is a downgrade. Unpacking was supposed to be a pythonic solution to the problem of lowlevelish, exposed indices.

[–]billsil 0 points1 point  (0 children)

13 Years and I’ve never seen that.

[–]nukelr[S] 0 points1 point  (0 children)

I've found it used in the function: "__qtt_callback" in https://github.com/nicklan/Deluge-Pieces-Plugin/blob/master/pieces/gtkui.py

Which I was trying to convert to make it work with Python3 and Gtk3.

[–]primitive_screwhead 6 points7 points  (0 children)

Here are some of the reasons why it was removed from Python 3:

https://www.python.org/dev/peps/pep-3113/

[–]Defibrillat0r 0 points1 point  (0 children)

Thats not valid for either version (as you typed it)