Positional-only and keyword-only arguments in Python
mCoding mCoding
233K subscribers
84,516 views
5.2K

 Published On Mar 28, 2022

Make function args positional or keyword-only.

In Python, it's possible to force a function argument to be positional-only or keyword-only. In this video, we see the syntax for doing this, as well as see some examples and reasons for why you might want to actually make a parameter positional-only or keyword-only.

Note: positional-only arguments are a Python 3.8+ feature. Keyword-only are Python 3.0+.

Errata:
1. At 1:22 you'll get a TypeError, not a SyntaxError.

― mCoding with James Murphy (https://mcoding.io)

Source code: https://github.com/mCodingLLC/VideosS...
Positional-only PEP: https://peps.python.org/pep-0570/
Keyword-only PEP: https://peps.python.org/pep-3102/

SUPPORT ME ⭐
---------------------------------------------------
Patreon:   / mcoding  
Paypal: https://www.paypal.com/donate/?hosted...
Other donations: https://mcoding.io/donate

Top patrons and donors: Jameson, Laura M, Dragos C, Vahnekie, John Martin, Casey G

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Discord:   / discord  
Github: https://github.com/mCodingLLC/
Reddit:   / mcoding  
Facebook:   / james.mcoding  

CHAPTERS
---------------------------------------------------
0:00 Intro
1:08 Keyword-only arguments
4:50 Positional-only arguments
7:45 Uncommon to use both
8:29 Speed test, position args are faster

show more

Share/Embed