Book Image

Python Essentials

By : Steven F. Lott
Book Image

Python Essentials

By: Steven F. Lott

Overview of this book

Table of Contents (22 chapters)
Python Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Summary


We've looked at a number of Python features for function definition. We've looked at how we define the name, and the parameters to a function, providing default values to make parameters optional. We've also looked at how we can provide arguments to a function: we can provide arguments by position, or by using the parameter variable name as a keyword. We can evaluate function(*args) to map a sequence of values to parameters by position. We can also evaluate function(**kw) to map a dictionary of values to parameters by name. And, of course, we can combine these two techniques.

We've looked at how functions return values via the return statement. We've also looked at functions which don't return a value. Technically, they return a value of None, which the rest of the Python programming ignores.

We've looked at the all-important issue of attempting to use a mutable object as a default value in a function definition. Most of the time, a mutable object as a default is going to create problems...