At what stage should a learner jump into the official documentation to figure things out?
If you say right away, you've probably forgotten what it's like to be at the very beginning of the journey
Here's an example…
/1
Take `range()`, for example, which many are curious about early on as they use it when learning the `for` loop (docs.python.org/3/library/stdt…)
Here's the first part of the docs:
/2
class range(stop)
class range(start, stop[, step])
The arguments to the range constructor must be integers (either built-in int or any object that implements the __index__() special method). If the step argument is omitted, it defaults to 1. If the start argument is ...
/3
As we have a one day's break from the Python functions series which returns with Day 10 tomorrow, let's look back the the topic from the last three days:
• positional-only arguments using / in function definitions
• keyword-only arguments using * in function definitions
/1
Why do we need them? Are they even ever used?
I bet you've seen them many times and ignored them. I'll go further and bet you've used them, too, without knowing
/2
Have you ever used `list.sort()` with the `key` or `reverse` parameters?
For those who've been following the #Python Functions Series, today we'll take a short break and Day 10 will return tomorrow – There's still a related-thread later today, but not directly part of the series.
So far we've covered:
• terminology (boring but useful)
• …
• Choosing to use arguments as either positional or keyword
• Using optional arguments by assigning default values
• *args and **kwargs, or variable number of positional and keyword arguments
• Using positional-only arguments, or the "rogue" forward slash / in functions
• …
• Using keyword-only arguments, or the "rogue" asterisk * in function signatures
Next up:
• type hinting
• general best-practices when defining and using functions