Tutorial using named arguments in Python

Posted in Uncategorized

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

In this tutorial, consider the following function that takes two arguments…

Yes, you can call the function like this …

greeting = greet('John', 'Doe')

But a better way is to call it using named arguments like this …

greeting = greet(last_name='Doe', first_name = 'John')

It has readability as to what the two arguments are. Plus it does not matter the order in which you put the arguments.


Related Posts

Tags

Share This