Positional-Only Parameters (/) e Keyword-Only Arguments (*)

This commit is contained in:
Luiz Otávio
2022-11-18 22:29:40 -03:00
parent d29a064ccf
commit 28df2b5052

16
aula145.py Normal file
View File

@@ -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')