(Jan-10-2020, 08:19 AM)Skaperen Wrote: if the caller does use * and/or **, does what the caller provides get passed through to the function as-is, or does it go through the argument handling mechanisms that give the function a tuple and dictionaryI think I show all possible variations in my example. You can do the same with your own type/class objects and see what the result is. Here it is again
from collections import OrderedDict def foo(*boo, **hoo): print(type(boo), boo) print(type(hoo), hoo) spam = [1, 2] eggs = OrderedDict((('a', 3), ('b', 4))) foo(*spam, **eggs) foo(spam, eggs) foo(5, 6, c=7, d=8)
Output:<class 'tuple'> (1, 2)
<class 'dict'> {'a': 3, 'b': 4}
<class 'tuple'> ([1, 2], OrderedDict([('a', 3), ('b', 4)]))
<class 'dict'> {}
<class 'tuple'> (5, 6)
<class 'dict'> {'c': 7, 'd': 8}
as you can see that when unpacked elements of the list are stored in a tuple and elements of the OrderedDict are stored in a dictwhen not unpacked you get list and OrderedDict as elements in a tuple.
bottom line - args/boo will be a tuple always, kwargs/hoo will be a dict always.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs