I have a list of uncertain size:
l = [...]
And I want to unpack this list into a tuple that has other values, but the below fails:
t = ("AA", "B", *l, "C")
How do I form the following?
t = ("AA", "B", l[0], ..., l[:-1], "C")
EDIT: it would also be nice to do a slice [a:b] only:
t = ("AA", "B", l[a], ..., l[b], "C")
As of python 3.5, you can now use your first approach:
You can use slices just as you'd expect:
The related PEP, for reference: PEP448