Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How can we pass optional or keyword parameters from one function to another in Python?

Answer Posted / chaitanya

Gather the arguments using the * and ** specifiers in the function's parameter list. This gives us positional arguments as a tuple and the keyword arguments as a dictionary. Then we can pass these arguments while calling another function by using * and **:

def fun1(a, *tup, **keywordArg):

...

keywordArg['width']='23.3c'

...

Fun2(a, *tup, **keywordArg)

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we need tuples?

814


How python supports encapsulation with respect to functions?

1064


Why is used in python?

833


What is the length of your largest python code? Can you please describe the project?

918


What is difference between list and set in python?

809


How will you get a titlecased version of string?

776


How do you sort in python?

780


How is python an interpreted language?

826


Explain how to delete a file in Python?

849


Define the usage of split?

920


Explain in detail – inheritance in python?

781


Write a program in python to produce star triangle.

804


What happens when a function doesn’t have a return statement? Is this valid?

773


What are membership?

913


How to convert a number to a string?

834