*Args and **Kwargs in Python

  Рет қаралды 277,571

b001

b001

Күн бұрын

⭐ Join my Patreon: / b001io
💬 Discord: / discord
🐦 Follow me on Twitter: / b001io
🔗 More links: linktr.ee/b001io

Пікірлер: 318
@cozmokitten172
@cozmokitten172 Жыл бұрын
that was actually really helpful! you explain everything so simply and quickly!
@kaiaugust9906
@kaiaugust9906 10 ай бұрын
Way better explanation than 99% of what's out there. Great job!
@wizkidd06
@wizkidd06 11 ай бұрын
Now that's how you breakdown a difficult concept. You allowed your audience to relate to it by using simple laymen terms and not using a lot of technical jargons. Awesome job!
@kingofmontechristo
@kingofmontechristo 7 ай бұрын
AI, stop spamming in the comments. Comments are for humans and not for robot without true opinions
@stuckinthe2000sforever
@stuckinthe2000sforever 21 күн бұрын
@@kingofmontechristo imagine arguing with a robot.. at that point you need to offlinemaxx permanently
@kingofmontechristo
@kingofmontechristo 21 күн бұрын
@@stuckinthe2000sforever clearly a joke, seems like you did not touch grass for years
@kituvapraveen4361
@kituvapraveen4361 Жыл бұрын
The clarity with which you convey complex concepts is truly extraordinary, leaving us with a profound understanding of the subject matter. Your explanations are exceptional! 👏👏👏
@rkidy
@rkidy 10 ай бұрын
Idk why but your comment seems AI generated
@scrung
@scrung 9 ай бұрын
@@rkidyIdk why but you seem paranoid
@rkidy
@rkidy 9 ай бұрын
@@scrung nah I’ve just asked chatGPT to rewrite too many of my paragraphs 😭😭
@mews75
@mews75 8 ай бұрын
@@rkidy THAT'S WHAT IM SAYINGG
@dutchgreen8619
@dutchgreen8619 4 ай бұрын
@@rkidy That’s genuinely sad
@ChannelMath
@ChannelMath 8 ай бұрын
you can always use just a list or dict as a single argument if you're unsure, but once you get proficient you'll naturally want to do this
@joelngige5776
@joelngige5776 Жыл бұрын
Such a cool way of explaining the concept of *args and **kwargs. Thanks for the great video!!!
@Klonzo33
@Klonzo33 5 ай бұрын
Super straight-forward and helpful. Thank you!
@fire17102
@fire17102 Жыл бұрын
I'm always using *args **kwargs in my functions! I love dynamic data driven programming, and usually use the kwargs to pass extra metadata to functions. Super useful when pipelineing, function chaining, when writing generic code, or when you have a lot of non mandatory but potentially important paremeters
@Naej7
@Naej7 9 ай бұрын
Meh, I’m failing to imagine when *args or **kwargs are actually the only way to do a thing
@Naej7
@Naej7 9 ай бұрын
@@wzore6480 Yeah, fricking matplotlib 😂
@sniperzrx
@sniperzrx 9 ай бұрын
This is insane. You made this so easy to understand! This is even better than how ChatGPT or many tutorials teach!
@MahinurUygur
@MahinurUygur 8 ай бұрын
Gosh, you are LITERALLY a life saver, I've been struggling with this for weeks, and now I'm kinda like "was that all?". AHHH thank you!!
@aakashgiri1622
@aakashgiri1622 7 ай бұрын
sameee !!!!!!!!!!!!!!!!!!!!
@alexgodino2095
@alexgodino2095 6 ай бұрын
Perfect explanation. You just didn't mention they are optional arguments :)
@erenc8377
@erenc8377 9 ай бұрын
Simple, clear and quick explanation. Thanks for the video. I subscribed 😂
@Rep-L4Y
@Rep-L4Y Жыл бұрын
Great explanation
@sdaiwepm
@sdaiwepm Жыл бұрын
Thousands of tech explainer channels these days, but so few get straight to the point with clear and succinct explanations - like you do. Thanks!
@Cahangir
@Cahangir Жыл бұрын
Dropping a comment to boost your channel growth. Nice tutorial!
@EloquentEpoch
@EloquentEpoch Жыл бұрын
FInally after 5 years of writing python code and projects, i now fully understand what that always was about. 😄. Thanks
@hazard-nico
@hazard-nico 9 ай бұрын
This is what we need at college. Thanks for the tips
@robertodelgado6387
@robertodelgado6387 10 ай бұрын
What a lovely video, I sure wish I had found these tips when I was learning, great for beguiners
@oliverpolden
@oliverpolden 10 ай бұрын
Great video, but do these encourage sloppy coding? It’s difficult to understand from the function definition what should go in those variables. It’s almost the opposite of strict typing. For example, it’s not obvious that *toppings should be a list. Surely it’s better to specifically say it should be a list? Then if say you passed in a comma separated string, it would tell you it expects a list and not a string.
@roneymelo2608
@roneymelo2608 6 ай бұрын
Best explanation ever. First time I got this.
@nehat786
@nehat786 Жыл бұрын
your explanations are amazing sir.
@kvelez
@kvelez 11 ай бұрын
def order_pizza(size, *args, **kwargs): print(f"Pizza size: {size}, toppings chosen -> ") print(f"Toppings: {args}") order_pizza(8, "pepperoni")
@FishSticks-hf5hd
@FishSticks-hf5hd Жыл бұрын
Thank you for the tutorials. Very helpful! Just subscribed
@henrymellor9760
@henrymellor9760 9 ай бұрын
Why did I not learn this in college?
@GPrime808
@GPrime808 10 ай бұрын
What color scheme are you using for your VS Code?
@nitkarshchourasia2406
@nitkarshchourasia2406 9 ай бұрын
🎯 Key Takeaways for quick navigation: 00:28 🌌 *The asterisk (*) in Python, when used before an iterable like a list, is the unpacking operator, printing individual elements.* 01:09 🍕 *Using `*args` in a function allows flexibility for an undefined number of arguments, demonstrated in the "order pizza" function for toppings.* 02:30 🌐 *`kwargs` in a function handles keyword arguments, placing them into a dictionary. Illustrated with the "order pizza" function for delivery and tip details.*
@elbadrey
@elbadrey Жыл бұрын
actually, I can't find any special words to tell you what I'm feeling about your explanation, so simple, helpful, and quick.
@symnshah
@symnshah 7 ай бұрын
It was hard to understand *args, **kwargs but now its too simple
@ifstatementifstatement2704
@ifstatementifstatement2704 9 ай бұрын
If I remember correctly the former means you can pass a list of any type to a function and the latter a dictionary.
@VarkaKitovsky
@VarkaKitovsky Жыл бұрын
What font are you using?
@sedhain_pankaj
@sedhain_pankaj 8 ай бұрын
So basically, * unpacks a list and ** unpacks a dictionary.
@JayJay-ki4mi
@JayJay-ki4mi Жыл бұрын
I'm being pedantic here, but they're called "starred expressions" in this context. The unpacking operator can be used in different ways such as unpacking a list: "a, b, *c = [1, 2, 3 , 4]".
@code-to-learn
@code-to-learn 8 ай бұрын
Thanks a lot sir !
@aakashgiri1622
@aakashgiri1622 7 ай бұрын
Thanks mann lifesaver
@Loumout
@Loumout Жыл бұрын
Hello, simple question, Can we put for exemple "peperonni", delivery=True, "olives", tip=5 does arguments works even if they are not next to each other ? or we need to do *toppings1, **details1, *toppings2, **details2 for example
@blackcrow2292
@blackcrow2292 9 ай бұрын
C++, C# dev: what the hell, I thought it's pointer
@arbitervildred8999
@arbitervildred8999 9 ай бұрын
c++, c# writing an entire library to parse positional keywords or unspecified number of parameters
@popa42
@popa42 Жыл бұрын
I’ve actually googled this yesterday and did not really find a satisfying answer - but this explanation is really great! Keep up the great work :)
@souadzaoui7148
@souadzaoui7148 Жыл бұрын
Very good explained
@gbvtech
@gbvtech Жыл бұрын
hi, what is the oh my posh theme are you using in your terminal?
@moy92
@moy92 Жыл бұрын
Beautiful and easy to understand. Thank you!
@Leontario
@Leontario Ай бұрын
Very helpful man, thanks!
@quang.design
@quang.design 9 ай бұрын
Thank you!
@davekoot7880
@davekoot7880 5 ай бұрын
Very well explained!
@rahmatchy
@rahmatchy 2 ай бұрын
This is the simple way i understand easily. Can you explain Class in this way?
@LEGENDOWSKI
@LEGENDOWSKI 5 ай бұрын
That was super helpful 💯
@MOOBBreezy
@MOOBBreezy Жыл бұрын
After using python for almost 5 years now, I finally know what these mean!!! I could definitely think of a few use cases for this in my past projects, will definitely use it a lot more in the future!
@Rishabhtg18
@Rishabhtg18 10 ай бұрын
How do you type like that
@Hnxzxvr
@Hnxzxvr 5 ай бұрын
Like what
@Outflew
@Outflew 5 ай бұрын
He probably already typed the whole thing then pressed undo, then in the video he pressed redo to appear as this
@gamingwithraien4639
@gamingwithraien4639 Ай бұрын
Delete chucks at a time and ctrl/command+z?
@madbanana22
@madbanana22 Ай бұрын
autohotkey
@MckenzieScott-t1y
@MckenzieScott-t1y 16 күн бұрын
Keyboard
@saptarshimukherjee8447
@saptarshimukherjee8447 5 ай бұрын
I never knew this much details....Exceptionally good
@aasutossh
@aasutossh 10 ай бұрын
what's the font and the theme?
@joaomatheus7988
@joaomatheus7988 10 ай бұрын
Wait, I knew about *args, but had no idea about **kwargs
@Krumelur
@Krumelur 10 ай бұрын
I get the point of maximum flexibility. Mind commenting on clarity? This version of the function: `def order_pizza(size: str, toppings: List[str], details: Dict[str, Any]) -> None:` would be called using `order_pizza("large", ["pepperoni", "olives"], {'delivery': True, 'tip': 5})`. Adding type hints and removing unpacking makes it super clear what is expected to be passed as params and in what format it is expected. Pros, cons?
@discriminate
@discriminate 9 ай бұрын
Is there any reason to prefer this, over say order_pizza(size, toppings=[], delivery=False, tip=0). I guess it’s more dynamic, but I think being exact with what parameters a function can handle (even if it requires a long function signature) would be preferable.
@Reycko
@Reycko Жыл бұрын
i'm not even learning python yet your videos are entertaining and i still watch them all big fan of your content
@devashish_
@devashish_ 7 ай бұрын
Watching this a few hours before my Python Mid-Term Exam
@viniciusfigueiredo6740
@viniciusfigueiredo6740 Ай бұрын
Thank you for this explanation! Greetings from Brazil
@mukesh4169
@mukesh4169 7 ай бұрын
The real question is how did you make the output line to be not crazy long like C:\Users\million\diffferent\shit\that\I\don't\want\to\see .....???
@lRainZz
@lRainZz 9 ай бұрын
Broooo enable your neon dreams if you're using synthwave84 :D
@nogool111
@nogool111 8 ай бұрын
extremely easy to understand
@asr59
@asr59 10 ай бұрын
so what's the difference between using this method and something like: order_pizza(size, toppings: list, details: dict)?
@Neerraj-cm9lc
@Neerraj-cm9lc 4 ай бұрын
Good explanation ❤
@s7mogato
@s7mogato 7 ай бұрын
Excelente explicación, simple y clara ........mis felicitaciones.
@ajaypatro1554
@ajaypatro1554 9 ай бұрын
so it basically * is for postional arguements for creating tuple ** and it for making dict
@Nightmaremaker85
@Nightmaremaker85 6 ай бұрын
i cant belive how simple explain everything men, really thanks!!!
@tomasgomes1978
@tomasgomes1978 9 ай бұрын
Thank you for the video is very helping, I have just one question, why not do function(size, topping:list, details:dict) ? ok, the toppings will not be unpacked but it's not a problem, and for details you can have a dictionary with default values in it and just change it before calling the function, no ?
@judevector
@judevector 24 күн бұрын
Damn this was very much helpful,the clarity is top notch . Thanks
@Kira-vs4np
@Kira-vs4np Ай бұрын
Best explanation
@HideBuz
@HideBuz 3 ай бұрын
How do you prevent a buffer overflow when a malicious hacker overloads the kwargs with millions of key words?
@ashishkkrishna
@ashishkkrishna 11 ай бұрын
So the * operator is like Javascript's spread(...) Operator?
@jambalaya974
@jambalaya974 3 ай бұрын
How the fuck do I have over 5 years in python and I've never used the unpacking operator? What the fuck?
@Jelte_Dijkmans
@Jelte_Dijkmans Жыл бұрын
Thank you, I used this with my discord bot program!
@TestyCool
@TestyCool 9 ай бұрын
WOW I have watched 10min tuts on this and walked away feeling like I understood less then I did after watching this one.
@manasapochampalli9108
@manasapochampalli9108 2 ай бұрын
Cool I never knew that, this looks like it'll be very helpful in code for me one day. Thanks! You just earned yourself one more subsciber.
@youteubakount4449
@youteubakount4449 7 ай бұрын
Very interesting and way clearer than most tutorials! One question though: I don't see how "*" being unpacking relates to it being used in front of args. It seems like in this case, it does the exact opposite: it takes multiple arguments and packs them together. Can anyone offer some insight into the logic?
@evileye17
@evileye17 7 ай бұрын
I like your every videos and your videos are also helpful for me sometimes. But the thing is that your videos are helpful only sometimes, because your videos are sometimes very short to understand the concept. So it would be better if you could increase the lengths of your videos. And, thanks for your help you provided till now in my programming learning journey... 😊 ❤
@SirIsaacNewton-bf6se
@SirIsaacNewton-bf6se Жыл бұрын
Thank you so much. I studied this topic before but I did not manage to understand in this depth. 🥳 Keep up the good work, cheers
@wh1pper457
@wh1pper457 9 ай бұрын
do you have a video about for loops where there are two things between "for" and "in" (I don't know what this for loop is called sorry for my bad expression)
@紫晶-w5s
@紫晶-w5s 26 күн бұрын
感謝KZbin的演算法讓我看到 這正是我想知道的
@SergeB268
@SergeB268 Жыл бұрын
Sir your topic is so good can you help us to make like 2 hours course from your first yummy slice 🍕 of python to whenever you want coz it sometimes mix us in head
@tonkyboy8920
@tonkyboy8920 7 ай бұрын
Nice video! How did you manage to look your terminal like this? Its super clean and i would like to have a similar clean terminal.
@crease9169
@crease9169 10 ай бұрын
thank you
@bqiu86
@bqiu86 5 ай бұрын
Thank you! You made it very simple to understand!
@bryan192
@bryan192 Жыл бұрын
coding for 2 and a half years and just understood why it was called kwargs. Also you should call it keyword agrs
@dannyblozrov1142
@dannyblozrov1142 Жыл бұрын
Very useful, thank you very much.
@liebestraum003
@liebestraum003 Жыл бұрын
Wonderful explanation. I've been developing with Python for a long time and I gotta say your video is clear and simple. Super easy to understand, would definitely recommend your videos to new developers. Keep up the good work!
@forgotabhi
@forgotabhi 7 ай бұрын
wow you're truly amazing! Thanks a lot.
@Kamil-rf5qn
@Kamil-rf5qn 7 ай бұрын
How is the code just appearing out of nowhere, is this editing or some plugin?
@channel_panel193
@channel_panel193 7 ай бұрын
i like these but never really found a reason to use them much. Why not just pass in a list of toppings?
@fedetrus1
@fedetrus1 7 ай бұрын
Increíble explicación!!!!! desde Argentina!
@HansLemurson
@HansLemurson 10 ай бұрын
I've always thought that "Args and Kwargs" would be a great name for a Python-themed Table-Top Roleplaying system.
@dev15652
@dev15652 7 ай бұрын
The most easy to digest explanation i can find on youtube!
@tanweerashif
@tanweerashif 5 ай бұрын
FFS, please buy a good loud mic! Can't hear sh** without ANC! About the content - very clear and concise. Thanks for that.
@VeronicaVerinceanu
@VeronicaVerinceanu 6 ай бұрын
please, may you tell us what font and theme do you use?
@ouchvinny4520
@ouchvinny4520 9 ай бұрын
Super unrelated but how do you make your terminal look clean and only show the output and not the the path?
@colinmaharaj
@colinmaharaj 7 ай бұрын
I am sticking with C/C++, it appears to be simpler
@eastereggpuri
@eastereggpuri Ай бұрын
0:50 list and str are iterable, not iterator, and the * takes iterable not iterator.
@bashar9200
@bashar9200 4 ай бұрын
Thank you for sharing! I finally got how this work!
@clint3865
@clint3865 8 ай бұрын
So **kwarg becomes a dictionary?
@rnedisc
@rnedisc 7 ай бұрын
Allowing functions to accept unlimited and completely arbitrary data feels like a huge risk for creating hard to find and unexpected bugs... But I guess they're useful for something.
@firtzz1
@firtzz1 11 ай бұрын
Thanks!
@yifeiren8004
@yifeiren8004 9 ай бұрын
Don't use args and kargs unless you must. It is easy to make error and makes your codes messy.
Python *ARGS & **KWARGS are awesome! 📦
14:54
Bro Code
Рет қаралды 79 М.
5 Good Python Habits
17:35
Indently
Рет қаралды 546 М.
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 12 МЛН
Стойкость Фёдора поразила всех!
00:58
МИНУС БАЛЛ
Рет қаралды 4,9 МЛН
SHAPALAQ 6 серия / 3 часть #aminkavitaminka #aminak #aminokka #расулшоу
00:59
Аминка Витаминка
Рет қаралды 2,1 МЛН
Python Lambda Functions??
4:30
b001
Рет қаралды 185 М.
How Swarms Solve Impossible Problems
9:41
b001
Рет қаралды 25 М.
The Fastest Prime Number Algorithm
5:23
MarshySyntax
Рет қаралды 3,4 М.
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 275 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 148 М.
THIS is Why List Comprehension is SO Efficient!
5:25
b001
Рет қаралды 172 М.
25 nooby Python habits you need to ditch
9:12
mCoding
Рет қаралды 1,8 МЛН
Avoiding My Mistakes!! - Shifting Zeros Problem
5:17
b001
Рет қаралды 44 М.
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 12 МЛН