Skip to content
Chandima's Blog
What you think you become.

Primary

  • SAUSECODE.COM
  • Blog
  • .LinkedIn
  • .Github
  • .Hackerrank
  • .About me

What is the usage of *args and **kwds in python?

Chandima October 20, 2018 apps, how to, learn, programming, python, tutorial args, kwds, opengl, pyqt, python

Usually i prefer to develop most of my products using a java related technology since i have lots of experience in java. But recently i have to deal with a new project and the project owner specifically asked us to develop that using python. That project was a interesting project to me not only because i have to develop that not using my favourite language but also it was actually a CAD application which we have to develop from the scratch. (Yes, i have done a research over the internet for the other options like similar opensource projects/ even checked whether i could include this as a plugin for famous opensource CAD softwares like FreeCAD. But they all seems to be not good enough solution for the project owners requirements)

Therefore, while i am doing some self learning about python (and all the things related to opengl, pyqt, pyqtgraph) i have came across this *args and **kwds argument in several sample codes.

Basically we can use both *args and **kwds to send variable number of arguments to a function. Note that you can use what ever name for them like *somename and **anothername. Usually eveyone tend to use *args and **kwds  as a convention. To get a clear idea see the following example.

def some_function(*args):
    for arg in args:
        print("arg =>",arg)

some_function("arg1","arg2","arg3")

Output
arg => arg1
arg => arg2
arg => arg3

So how different **kwds from *args? Unlike *args , **kwds can be used to send named arguments.
Since there is no point in rewriting examples, take a look at the following blog post for some nice examples and more information.
https://pythontips.com/2013/08/04/args-and-kwargs-in-python-explained/

How to remove annoying virtual network interfaces added by the VirtualBox [vmnet1, vmnet8] [Linux]PREV
How to use a secure public url for your localhost [Dev Purpose] [ngrok]NEXT

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary

Search the blog!

Recent Posts

  • Familiarize with these tools before going to Industry May 8, 2021
  • How to let the scripts run in the background [ssh] June 6, 2020
  • NoSQL vs SQL Databases in a Nutshell June 5, 2020
  • SSH to a host through multiple jump hosts. [Linux] April 30, 2019
  • GNU – Octave [matlab equivalent for linux] – This is how you can install packages January 22, 2019

Categories

  • android (11)
  • applications (2)
  • apps (4)
  • arduino (2)
  • avr (1)
  • blog-android (2)
  • blog-arduino (1)
  • computer science (1)
  • database (1)
  • embedded (1)
  • emui (1)
  • games (1)
  • home made (2)
  • Honor 3c (6)
  • how to (15)
  • huawei (6)
  • java (4)
  • kali (7)
  • kitkat (1)
  • learn (10)
  • linux (11)
  • networking (6)
  • octave (1)
  • PC Apps (1)
  • pi4j (1)
  • programming (3)
  • pyqt (1)
  • python (2)
  • raspberry pi (1)
  • remote controlled (1)
  • Server (3)
  • tech (4)
  • tutorial (8)
  • Verilog (1)
  • windows (6)

Tags

2018 aero plane android Android 4.4.2 android app player android apps on windows class cross-platform file honor 3c honor 3c custom unicode honor 3c sinhala how how to how to install how to install custom unicode huawei honor 3c install custom font in honor 3c install custom unicode install unicode interfaces java kali language linux network opengl programming pyqt python remote run scripts server sinhala sinhala app sinhala for huawei sinhala installer sinhala unicode sinhala unicode for honor 3c sinhala unicode installer sinhala unicodes Sri Lanka ssh to

Archives

  • May 2021
  • June 2020
  • April 2019
  • January 2019
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • April 2018
  • March 2018
  • October 2017
  • February 2017
  • June 2016
  • July 2015
  • January 2015
  • December 2014
  • November 2014

"I hear and I forget, I see and I remember, I do and I understand." ~ Confucius

© Copyright 2020 SAUSECODE LABS | Chandima Samarasinghe