S
Steven D'Aprano
I'm trying to understand the use of tuples in function argument lists.
I did this:
.... print a, b, c
.... Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 1, in tester
TypeError: unpack non-sequence
That was obvious result.
ab a b
And so were those.
Then I tried this:
.... if (b,c) is None:
.... print a, None
.... else:
.... print a, b, c
Needless to say, it did not do what I expected it to do. I didn't expect
it to either
I tried looking at the language reference here:
http://docs.python.org/ref/function.html
but I can't seem to find anything in their that says that tuples-as-args
are legal. Am I misreading the docs, or is this accidental behaviour that
shouldn't be relied on?
Does anyone use this behaviour, and if so, under what circumstances is it
useful?
I did this:
.... print a, b, c
.... Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 1, in tester
TypeError: unpack non-sequence
That was obvious result.
ab a b
And so were those.
Then I tried this:
.... if (b,c) is None:
.... print a, None
.... else:
.... print a, b, c
Needless to say, it did not do what I expected it to do. I didn't expect
it to either
I tried looking at the language reference here:
http://docs.python.org/ref/function.html
but I can't seem to find anything in their that says that tuples-as-args
are legal. Am I misreading the docs, or is this accidental behaviour that
shouldn't be relied on?
Does anyone use this behaviour, and if so, under what circumstances is it
useful?