[issue33103] Syntax to get multiple arbitrary items from an iterable

2018-03-21 Thread AmjadHD
AmjadHD added the comment: Yes that's a way to do it but "a, b, c = my_list[1, 3, -1]" seems so pythonic and straight forward, it's like formatting, python had already 3 methods to do it when it introduced a 4th one (f-strings), easier is better especially in

[issue33103] Syntax to get multiple arbitrary items from an iterable

2018-03-19 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, there is already a way to do this but it involves the extra step of applying map() to a bound method: >>> my_list = ["John", "Richard", "Alice", 1, True, 2.1, "End"] >>> a, b, c = map(my_list.__getitem__, [1, 3, -1]) >>>

[issue33103] Syntax to get multiple arbitrary items from an iterable

2018-03-19 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: This syntax already is supported for dicts and NumPy arrays, but with different semantic. >>> d = {(1, 2): 'foo'} >>> d[1, 2] 'foo' >>> a = numpy.array([[1, 2], [3, 4]]) >>> a[1, 0] 3 -- nosy: +serhiy.storchaka

[issue33103] Syntax to get multiple arbitrary items from an iterable

2018-03-19 Thread amjad ben hedhili
Change by amjad ben hedhili : -- title: Syntax to get multiple items from an iterable -> Syntax to get multiple arbitrary items from an iterable ___ Python tracker