Загрузка...

You’re Using Python Functions Wrong 😳 | *args & **kwargs Trick! #coding #shorts

Most developers know about *args and **kwargs in function definitions—but did you know you can use them in function calls too?

Here’s how it works:

def greet(name, age):
print(f"Hello {name}, you are {age} years old.")

info = ["Alice", 25]
greet(*info) # Works perfectly!

data = {"name": "Bob", "age": 30}
greet(**data) # Also works!

This powerful unpacking syntax keeps your function calls clean and dynamic.

It’s a super underrated trick that makes your code more Pythonic, especially when dealing with lists or dictionaries.

👉 Subscribe to @CodeSnap-UR for more Python tips that most developers overlook!

#PythonTips #PythonHacks #argsKwargs #PythonTrick #CodingShorts #CodeSnap

Видео You’re Using Python Functions Wrong 😳 | *args & **kwargs Trick! #coding #shorts канала CodeSnap
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять