*args and **kwargs in Python

Naveen (Trainer, Mentor)
2 min readMar 15, 2023

--

Introduction

In Python, we can pass a variable number of argumnets to a function using special symbols.

THere aer two special symbols

  1. *args (Non Keyword Arguments)
  2. **kwargs (Keyword Arguments)

Note : We use *args and **kwargs as an argument when we have no doubt about the number of arguments we should pass in a function.

*args

The special syntax *args in function definition in python is used to pass a variable number of arguments to a function.

**kwargs

**kwargs in function definition us used to pass a keyword variable length argument list,

We use the name kwargs with the double star. THe reason is that the double star allows us to pass through keyword arguments (and any number of them).

kwargs stands for keyworded arguments

Thanks for Reading!

If you like my work and want to support me…

  1. The BEST way to support me is by following me on Medium.
  2. I share tips, tricks and insights on #softwareengineering, #dataengineering #cloud #ml on LinkedIn.
  3. Feel free to give claps so I know how helpful this post was for you.

Do you want to connect with me I have started mentoring others for career and interviews at 𝐭𝐨𝐩𝐦𝐚𝐭𝐞.𝐢𝐨/𝐧𝐚𝐯𝐞𝐞𝐧𝐩𝐧

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Naveen (Trainer, Mentor)
Naveen (Trainer, Mentor)

Written by Naveen (Trainer, Mentor)

I am a corporate trainer having 12+ yrs of experience in Software Engineering, Data Engineering, Cloud , AIML - Book a session www.topmate.io/naveenpn

No responses yet

Write a response