Variable Function Arguments in Python. *args, **kwargs

The use of args and kwargs in Python has often confounded me.

Few notes from Data Science From Stratch:

  • The asterisk performs argument unpacking, which uses the elements of pairs as
    individual arguments
  • That is, when we define a function like this, args is a tuple of its unnamed arguments and kwargs is a dict of its named arguments.






Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s