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

What does means by split do in python?

1072


How would you perform unit-testing on your python code?

833


Write a command to convert a string into an int in python.

921


What is the difference between .py and .pyc files?

834


What is abs in python?

819


Why is python faster than r?

860


How does xrange work in python?

824


Explain list, tuple, set, and dictionary and provide at least one instance where each of these collection types can be used.

907


How does ternary operator work in python?

932


Whenever you exit python, is all memory de-allocated?

896


What is the difference between Python and PHP?

929


What is the best python interpreter?

901


How to delete a file in python?

1068


Are tuples hashable?

829


What does %d do in python?

885