Some Best Practices When Writing Python Functions [Intermediate Python Functions Series #7]

You've covered a lot of material in this Intermediate Python Functions Series. In this final article, you'll read about some best practices in Python functions. This topic is different from the previous ones discussed in this series. You won't get a SyntaxError, TypeError or any other error if you don't follow best practices. Your code… Continue reading Some Best Practices When Writing Python Functions [Intermediate Python Functions Series #7]

Using Type Hints When Defining A Python Function [Intermediate Python Functions Series #6]

You've already covered a lot of ground in this Intermediate Python Functions series. In this article, you'll read about a relatively new addition in Python called type hinting or type annotation. Unlike all the other topics you learnt about in the previous articles, this one will not change the behaviour of the function you define.… Continue reading Using Type Hints When Defining A Python Function [Intermediate Python Functions Series #6]

Using Positional-Only And Keyword-Only Arguments in Python [Intermediate Python Functions Series #5]

Cogwheels (steampunk style) to represent Python functions

In previous articles in this series, you read about positional and keyword arguments, making arguments optional by adding a default value, and including any number of positional and keyword arguments using *args and **kwargs. In this article, it's the turn of another flavour of argument. You'll look at parameters that can only accept positional arguments… Continue reading Using Positional-Only And Keyword-Only Arguments in Python [Intermediate Python Functions Series #5]

Argh! What are args and kwargs in Python? [Intermediate Python Functions Series #4]

cogs and wheels used to represent functions in the args and kwargs in Python article

In the first three articles in this Series, you familiarised yourself with the key terms when dealing with functions. You also explored positional and keyword arguments and optional arguments with default values. In this article, you'll look at different types of optional arguments. Rather unfortunately, these are often referred to by the obscure names args… Continue reading Argh! What are args and kwargs in Python? [Intermediate Python Functions Series #4]

Optional Arguments With Default Values in Python Functions [Intermediate Python Functions Series #3]

Steampunk hat with goggles

We continue our journey through Python functions by looking at optional arguments and default values. In this article, you'll see how you can define a function with an optional argument. A default value is used if the argument is not included in the function call. Overview Of The Intermediate Python Functions Series Here's an overview… Continue reading Optional Arguments With Default Values in Python Functions [Intermediate Python Functions Series #3]

Using Positional Arguments and Named or Keyword Arguments in Python Functions [Intermediate Python Functions Series #2]

Image of steampunk gears used to represent Python functions

In the first article in this Intermediate Python Functions Series, you made sure you got your terminology right. So you know what an argument is. But what are positional arguments and keyword arguments in Python? In this article, you'll see how you can choose to use either of the two in many situations. Later in… Continue reading Using Positional Arguments and Named or Keyword Arguments in Python Functions [Intermediate Python Functions Series #2]

Moving On From The Basics of Python Functions [#1 in Intermediate Python Functions Series]

Steampunk-themed cogs to represent Python functions

Those learning to code learn about functions very early on in their journey. Not only do beginners use Python functions right from their first lesson, but they also learn to define their own Python functions early on. It may be tempting–and in my experience, it's a common pitfall early on–for a relative beginner to think… Continue reading Moving On From The Basics of Python Functions [#1 in Intermediate Python Functions Series]

Understanding Python Functions With The Function Room (The White Room Series #2)

Python functions as doors

You've probably already learned about defining functions in Python and how to add parameters and return statements. You may even have learned about more advanced features of Python functions. But can you picture exactly what they do and what's really happening behind the scenes when you call a function? In this blog, I'll build on… Continue reading Understanding Python Functions With The Function Room (The White Room Series #2)