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].

Python: Formatting a string using variable names placeholders

Consider the following string building statement: s="svn cp %s/%s/ %s/%s/" % (root_dir, trunk, root_dir, tag) Using …

python string-formatting iterable-unpacking
How can I explode a tuple so that it can be passed as a parameter list?

Let's say I have a method definition like this: def myMethod(a, b, c, d, e) Then, I have a …

python parameters tuples iterable-unpacking
Unpacking tuples in a python list comprehension (cannot use the *-operator)

I am trying to create a list based on another list, with the same values repeated 3 times consecutively. At the …

python tuples list-comprehension iterable-unpacking
Returning tuple with a single item from a function

Just came across this little bit of weirdness in Python and thought I'd document it write it as a question …

python function return-value iterable-unpacking
Python: unpack to unknown number of variables?

How could I unpack a tuple of unknown to, say, a list? I have a number of columns of data …

python casting iterable-unpacking
Python: Splat/unpack operator * in python cannot be used in an expression?

Does anybody know the reasoning as to why the unary (*) operator cannot be used in an expression involving iterators/lists/…

python python-2.7 iterable-unpacking argument-unpacking pep448
Is there way to create tuple from list(without codegeneration)?

Sometimes there are needs to create tuples from small collections(for example scalding framework). def toTuple(list:List[Any]):scala.…

scala tuples iterable-unpacking
Python - tuple unpacking in dict comprehension

I'm trying to write a function that turns strings of the form 'A=5, b=7' into a dict {'A': 5, 'b': 7}. …

python dictionary iterable-unpacking dictionary-comprehension
Python: Unpacking an inner nested tuple/list while still getting its index number

I am familiar with using enumerate(): >>> seq_flat = ('A', 'B', 'C') >>> for num, entry …

python list tuples enumerate iterable-unpacking
python: when can I unpack a generator?

How does it work under the hood? I don't understand the reason for the errors below: >>> def …

python args iterable-unpacking