Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Setting Default Values

00:00 Let’s maybe create a couple more functions here.

00:07 What should we call this? Like no defaults, standard_no_defaults(). Yeah.

00:23 Okay. Good here. All right. So if we look at standard_no_default(), you can actually pass in those arguments as keyword arguments, right?

00:42 And you can also do it as just plain, plain old positional arguments as well. And you can do a combination, and you can actually do a combination with all three of these standard functions.

00:55 Except with standard_defaults(), where all of them have defaults, you can call them without any arguments because they have defaults, whereas if you have no defaults, you actually get NameErrors because—oh, wait, that’s not the right one, default.

01:17 TypeErrors because you need those three positional arguments. And here it’s also really nice in the output, you can see that it’s called positional arguments. Right.

01:29 So despite the fact that they have these default values with the equal sign in between, which makes them look like you might expect them to be keyword arguments, they’re still positional arguments in this case from Python’s perspective.

01:42 Yeah. The key distinction here is that for the function definition, they are parameters in the sense that the parameters are defined either as normal parameters—I think normal in this case is where they can be either a positional or keyword argument—but when you’re calling the function, you’re using either arguments or keyword arguments.

02:04 So when you are defining the function, you use parameters. When you call the function, you use arguments. Nice.

Become a Member to join the conversation.