python - What is the difference in *args, **kwargs vs calling with tuple and dict? -


this question has answer here:

this basic question. there difference in doing

def foo(*args, **kwargs):     """standard function accepts variable length."""     #  foo(v1...vn, nv1=nv1...nvn=nvn)  def foo(arg, kwargs):     """convention, call tuple , dict."""     #  mytuple = (v1, ..vn) mydict = {nv1=nv1, ...nvn=nvn} foo(mytuple, mydict) 

i same thing both, except later has weird convention of creating tuple , dictionary. there difference? can solve same computational problem of handling infinite things because dict , tuple can take care of me anyway?

is more of idiomatic part of python i.e syntactic sugar things anyway? i.e function going handle you!

ps: not sure of many downvotes though agree copy of why use packed *args/**kwargs instead of passing list/dict? , should corrected in duplicate information. , question has recieved upvotes. being downvotes not being able find that?

args , kwargs names.
matters here * , **.

in second example can call function 2 arguments, against first example can call function infinite arguments.


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -