From 28df2b505248c8323c6119f318b3bf88ebebef9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Ot=C3=A1vio?= Date: Fri, 18 Nov 2022 22:29:40 -0300 Subject: [PATCH] Positional-Only Parameters (/) e Keyword-Only Arguments (*) --- aula145.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 aula145.py diff --git a/aula145.py b/aula145.py new file mode 100644 index 0000000..c6ed078 --- /dev/null +++ b/aula145.py @@ -0,0 +1,16 @@ +# Positional-Only Parameters (/) e Keyword-Only Arguments (*) +# *args (ilimitado de argumentos posicionais) +# **kwargs (ilimitado de argumentos nomeados) +# 🟢 Positional-only Parameters (/) - Tudo antes da barra deve +# ser ❗️APENAS❗️ posicional. +# PEP 570 – Python Positional-Only Parameters +# https://peps.python.org/pep-0570/ +# 🟢 Keyword-Only Arguments (*) - * sozinho ❗️NÃO SUGA❗️ valores. +# PEP 3102 – Keyword-Only Arguments +# https://peps.python.org/pep-3102/ +def soma(a, b, /, *, c, **kwargs): + print(kwargs) + print(a + b + c) + + +soma(1, 2, c=3, nome='teste')