Positional-Only Parameters (/) e Keyword-Only Arguments (*)
This commit is contained in:
16
aula145.py
Normal file
16
aula145.py
Normal 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')
|
||||
Reference in New Issue
Block a user