0

Let's say I have a tuple

t = (1, 2, 3)

and a function

def test(a, b, c):
    print a + b + c

I could then call

test(t[0], t[1], t[2])

Is there a more elegant way to do this for a large tuple (or other data type, e.g. list)? Like so:

test(t.unpack_as_args())

What syntax can I use in place of t.unpack_as_args()?

noumenal
  • 1,077
  • 2
  • 16
  • 36
  • @jonrsharpe Thanks! I think the question can be kept as it is, as one is about semantics and the other about syntax. – noumenal May 27 '16 at 13:55
  • 5
    But you're asking about syntax, not semantics. – jonrsharpe May 27 '16 at 13:56
  • @jonrsharpe Yes, I thought that's what I said. Actually, this question is the answer to the other question. Vice versa, your answer is the other question. – noumenal May 27 '16 at 14:03
  • I haven't answered, these are comments. Your post is a question, whose answer appears in the answers of another question, hence duplicate. – jonrsharpe May 27 '16 at 14:11
  • @jonrsharpe I just want to help people who search from the other end of the problem. If you don't want to take credit for your words that's fine. – noumenal May 29 '16 at 07:52
  • Your comments have the right kind of words, but don't make any sense or relate to the preceding comment. Are you a bot? – jonrsharpe May 29 '16 at 07:56
  • @jonrsharpe I'm not a bot :) I just didn't want to get philosophical about the difference between a Stackoverflow answer and a semantic answer. Semantic answers can be found in Stackoverflow comments and some Stackoverflow answers are semantically just comments. If I asked What do strawberries taste like? and someone else asked What happens if I put these red thingies in my mouth? the questions carry different semantic contents. The answer is the same, but because the two questions differ in meaning, they are not exact duplicates. – noumenal May 29 '16 at 08:10
  • Please note that the definition of duplicate on SO says *This question already has an answer here*; that's the important bit, not whether the two *questions* are semantically or otherwise identical. For someone trying to avoid an argument, you seem surprisingly keen to continue it. Also we avoid opinion-based questions about strawberries! – jonrsharpe May 29 '16 at 08:14
  • I have been called many things, but never a bot. I appreciate that some aspects of your comment actually refers to the topic and not to my person and on those points I agree. – noumenal May 29 '16 at 09:43
  • 1
    You're just determined to prove my point, huh? Go ahead, have the last word: – jonrsharpe May 29 '16 at 09:47

0 Answers0