Can anyone explain the difference when unpacking the dictionary using a single or a double asterisk? You can mention their difference when used in function parameters, only if it is relevant here, which I don't think so.
However, there may be some relevance, because they share the same asterisk syntax.
def foo(a,b)
return a+b
tmp = {1:2,3:4}
foo(*tmp) #you get 4
foo(**tmp) #typeError: keyword should be string. Why it bothers to check the type of keyword?
Besides, why the key of dictionary is not allowed to be non-string when passed as function arguments in THIS situation? Are there any exceptions? Why they design Python in this way, is it because the compiler can't deduce the types in here or something?
foo(1=2, 3=4)
which doesn't make any sense. Keyword arguments must be a valid identifier. – Squadrondict
s guaranteed to be composed exclusively of strings (which a lot of implementation internals happen to be), so the rejecting non-strings ensures strings can go through the fastest code paths (speeding up all Python code). – Delmore