Top "Iterable-unpacking" questions

A Python feature in which elements of an iterable are simultaneously assigned to multiple variables, e.g. a, b, c = [1, 2, 3].

ValueError: too many values to unpack (expected 2)

In the Python tutorial book I'm using, I typed an example given for simultaneous assignment. I get the aforementioned ValueError …

python input iterable-unpacking
Meaning of using commas and underscores with Python assignment operator?

Reading through Peter Norvig's Solving Every Sudoku Puzzle essay, I've encountered a few Python idioms that I've never seen before. …

python syntax iterable-unpacking
Is there a more elegant way for unpacking keys and values of a dictionary into two lists, without losing consistence?

What I came up with is: keys, values = zip(*[(key, value) for (key, value) in my_dict.iteritems()]) But I …

python list dictionary iterable-unpacking
What does *tuple and **dict mean in Python?

As mentioned in PythonCookbook, * can be added before a tuple. What does * mean here? Chapter 1.18. Mapping Names to Sequence Elements: …

python python-3.x tuples namedtuple iterable-unpacking
Tuple Unpacking in Map Operations

I frequently find myself working with Lists, Seqs, and Iterators of Tuples and would like to do something like the …

scala map iterator tuples iterable-unpacking
How to unpack tuple of length n to m<n variables

In Python 3 I can do the following (see also PEP3132 on Extended Iterable Unpacking): a, *b = (1, 2, 3) # a = 1; b = (2, 3) What can …

python iterable-unpacking
Unpacking, extended unpacking and nested extended unpacking

Consider the following expressions. Note that some expressions are repeated to present the "context". (this is a long list) a, …

python python-3.x iterable-unpacking argument-unpacking
Ignore part of a python tuple

If I have a tuple such as (1,2,3,4) and I want to assign 1 and 3 to variables a and b I could …

python tuples iterable-unpacking
Why is Scala's syntax for tuples so unusual?

In mathematics and computer science, a tuple is an ordered list of elements. In set theory, an (ordered) n-tuple is …

scala tuples iterable-unpacking
Python update object from dictionary

Is there a built-in function/operator I could use to unpack values from a dictionary and assign it into instance …

python iterable-unpacking