👷 Join the FREE Code Diagnosis Workshop to help you review code more effectively using my 3-Factor Diagnosis Framework: www.arjancodes.com/diagnosis
@Aviel777Gergel Жыл бұрын
Python has a simple syntax, and this make people accidentally think that they good at it. Thanks to you, we can actually be good at it. Your content helped me to significantly improve my code quality. I hope your content will get much more views, because it super great, interesting and informative.
@ArjanCodes Жыл бұрын
Thank you so much for the kind words, Aviel!
@matiasmercado3304 Жыл бұрын
Hello Arjan. Thanks for your content, it helps me a lot to improve my skills. You are basically the senior I wish I had had
@ArjanCodes Жыл бұрын
Thank you so much for your kind message!
@NicoPfeffer3 ай бұрын
Wow 😮 I really enjoyed the validator higher-order function section. I'll start implememting this. Thanks for your well made tutorials and the efforts. :D
@ArjanCodes3 ай бұрын
Thank you!
@AllanHansen-n1d Жыл бұрын
I think overwriting the __str__ and __repr__ is often a good idea, so IMHO those are exceptions to the rule about being careful overwriting the dunder-methods.
@kicknotes Жыл бұрын
One thing I've noticed is that devs will often learn a language by going through example exercises solving specific problems... While this is good, I've always found it better (for me, at least) to instead try to write code utilizing every element of a language (with the focus more on "coverage" than specific problems). In the case of Python, I made a point to write code implementing every single dunder method available in Python, and I think doing so was a *very* worthwhile effort (one that I'd suggest to other devs, in fact). Good video, as always!
@KAYounes Жыл бұрын
Would you suggest any resources to do so?
@kicknotes Жыл бұрын
@@KAYounes Really just the language documentation, or (if available) the source code to any standard library/framework. In the case of Python, I just looked up "data model methods" and started there. I also browse the source code of modules in the standard library and if I find something I've never seen before, I look it up, try to understand it, and then try to use it in my own code (even if just a one-liner). With C#, for example, I just dug through the .NET framework source code and did the same thing. Every time I found an operator (??, for example) or a keyword (unsafe, for example) that I hadn't seen/used, I made a point of writing a line or two of code that used what I just found.
@gmarcosoldo Жыл бұрын
Omg this is content is AMAZING!! It's everything I would want in an educational programming video. Please keep using this format!
@ArjanCodes Жыл бұрын
Thank you so much!
@gonecoastaltoo Жыл бұрын
The __get__ dunder method is used to define a descriptor, which provides a nifty means of designing declarative syntax for composing complex object relations. This one is really easy to misuse or over-use, but used correctly it adds a super-power that I've not seen in other languages. @Arjan, maybe you could do a video on appropriate design and uses for descriptors and the __get__ dunder method? Most of the tutorials I've seen only scratch the surface and fail to reveal the power of this feature.
@jeancerrien3016 Жыл бұрын
Another problem with the example @13:06 is that one must modify the base class whenever you create a new subclass. One could use a factory method instead.
@rzimmerdevАй бұрын
Yeah, he technically went halfway with the create_payment function, just needed to put it in a factory class. I think since he wasn't going to reference it elsewhere the function was correct for the use case specifically and much less heavy to understand for this video, but a factory method would be correct in any other scenario.
@tikendraw Жыл бұрын
Hello arjan. I love watching you videos. Can you make video on handling paths while modularizing code. I am trying to find ways and haven't came across any good video explaining path handling.
@akhiljp5352 Жыл бұрын
Me to
@lukekurlandski7653 Жыл бұрын
Great video! While I do not disagree with the overall message, I slightly disagree with the example presented at 8:40. The two `validator' examples are not equivalent because the class-based option lets you mutate the validators while the function-based option does not. Therefore, there are conceivably some scenarios where the second solution would be much less efficient than the first...
@iandthopper Жыл бұрын
My favorite Python content. Thank you, Arjan.
@thisoldproperty Жыл бұрын
Awesome video. I learnt something new today with dunder iterator. Thank you!
@ArjanCodes Жыл бұрын
Great to hear!
@the_coding_nick Жыл бұрын
Great job to Arjan for teaching Python information so well and accurately! Teaching a programming language like Python requires patience, clarity, and the ability to convey complex concepts in a simple and understandable language
@ArjanCodes Жыл бұрын
Thanks a lot!
@Andrumen01 Жыл бұрын
Yes, your message is on point, I think. Use "dunder" methods if you really really really really need to! If there are less "really" statements, just don't use them. They make the code bulkier and more difficult to maintain. Yes, they are there to be used, but use them sparingly.
@padraic1983 Жыл бұрын
Hey Arjan, would love to see a video on sqlmodel !
@DrDeuteron Жыл бұрын
btw: if you want to do coordinate independent scalar products on your vectors, define a norm: def __abs__(self): return pow(self.x**2 + self.y**2, 1/2) and then: def __mul__(self, other): return (abs(self + other)**2 - abs(self - other)**2) / 4 works on any vector with a norm, without regards to internals.
@__christopher__ Жыл бұрын
And wastes a lot of time doing a square root just to square it afterwards. I think this falls under the performance argument from the video.
@__christopher__ Жыл бұрын
Also a mathematical note: Unless the normal is defined by a scalar product to begin with, your "scalar product" won't have the properties of a scalar product. Which also violates the principle of least surprise.
@EW-mb1ih Жыл бұрын
at 15:25, wouldn't be better to use a dict instead of the if-block in the function? The function would be more maintainable if we added new payment class
@MichaelRawson Жыл бұрын
Massive like for the classic Batman reference alone!! Love your work, Arjan
@Hernell12 Жыл бұрын
4:20 also overwrite the __bool__ method for easy boolean expressions with the emulating class
@sethstenzel Жыл бұрын
I don't know if you are trolling us or not, but Spiderman is Marvel, and Batman is DC :) Either way, love the reference. I, not so secretly, hope it was intentional just to annoy folks.
@ArjanCodes Жыл бұрын
Haha. I did take a bit of creative freedom there as I really like the Batman transitions 😊.
At 9:02, in c1_before.py line 6 typing.List should be used instead of default list class due to not being subscriptable on older python versions.
@frackinfamous6126 Жыл бұрын
Also funny thing. I watch you already but I was watching a comic video when this popped up. So.... you know what I'm saying. Google is def using auditory keywords. Keep up the great content.
@ArjanCodes Жыл бұрын
Thanks so much!
@DrDeuteron Жыл бұрын
at 6:11, I would return type(self)(...). not Vector(...)...b/c you never know. I would also, to avoid writing more code do subtraction via: def __neg__(self): return type(self)(-self.x, -self.y) def __sub__(self, other): return self + (-other)
@cv7245 Жыл бұрын
"holy list comprehension!" - I want that on a t-shirt :)
@frozeneye100 Жыл бұрын
Lol. Then I tell python Dundee dunder yourself a dunder str. It tells me I am an idiot because that is not way this works. If you guys need a lesson on how to make python scream at you. Please let me know. I can do Arjan in the opposite way. As always. Good video and you are one of few people that makes things sound simple but not giving the this is how to solve your problem but showing well how the things work. Very very well laid out and some still a bit beyond my skill level. But it is so good to see this type of thing and not a hello world program and really challenging to go read more documents. Well done as always for making it clear where there is room for self improvement. Depending where you are. Doing the time things difference I am astonished it is quicker way you did. But it does sort of feel like you start with functions then objects then class then get stuck dunder everything because it works. Just to take it all way back to what seems you were doing while learning. It really is a running on mill and explore and mess up so much. Unfortunately that idea still has not clicked because still exploring and trying to make ends of things.
@markgyamfi2144 Жыл бұрын
Thanks for the great video. The payment processor example would have been a great opportunity to flex with a match case besides the str enum. Or maybe thats already to old to boast with... darn that new release cycle😀. As a german when I see the __eq__ method I always think about the german words "dasselbe" and "das gleiche" which as a kid made me stumble. Maybe we need a __equal__ and __same__ method also in python to up the ante.
@Just2Dimes Жыл бұрын
You have the 'is' keyword. Doesn't that do what you're wishing for here?
@markgyamfi2144 Жыл бұрын
@@Just2Dimes yes the is keyword checks for the reference. There is probably a way to implement a vector in a similar way as a simple number where assigned variables would have the same reference… but I dunno how or if there is a __same__ method that you could (would guess not).
@TimoRJensen Жыл бұрын
Lovely!
@bigutubefan2738 Жыл бұрын
You could just use contextlib instead of dunder methods for DatabaseConnection. I know inheritance is unpopular and composition is favoured, but even Bank would be greatly simplified by making it a subclass of a list, instead of messing around with dunders.
@frackinfamous6126 Жыл бұрын
Good morning sir, thanks for the new video and the comic cringe at the beginning. Let the comments fly. Smart... haha.
@RatafakRatafak Жыл бұрын
It’s not only higher order function it’s also closure:)
@johantoday Жыл бұрын
hey Arjan, i really like your video's but the background music is a bit distracting
@ArjanCodes Жыл бұрын
Hi, thanks for flagging it! :)
@codingwithmrward1648 Жыл бұрын
A good addition to that vector class would be `__radd__` so a list of vectors can be passed to sum()
@DrDeuteron Жыл бұрын
and __rmul__ for dilation.
@ifeoluwaadeoye6557 Жыл бұрын
Me just realising DoubleUNDERscore is where "dunder" stems from 😂
@edgeeffect9 ай бұрын
Um... "Marvel mode"... "Batman".... do you realise how many comic nerds you've probably just offended with that juxtaposition? ;)
@ipadista Жыл бұрын
As always interesting vid! 4:03 in your Account class, why do you call the account ID "number"? Nowadays all banks use IBAN as the account ID, so iban would be a more relatable name both in that class and the Bank class iban would also be an excellent thing to display in `Account.__repr__`
@Just2Dimes Жыл бұрын
Probably because everyone will understand "number", but not everyone is equally familiar with IBAN, given that it's not used all over the world.
@RileyGein Жыл бұрын
Also IBAN stands for International Bank Account Number. Either way you’re calling it a number
@appuser Жыл бұрын
18:00 but isn't that just because of the way the dunder method was used, not really to do with it being a dunder method?
@PiotrDrzymkowski Жыл бұрын
Donald methods Dominant methods Donor methods Dolar methods Dama methods :D
@frantisekcastek174 Жыл бұрын
@All: Guys, do you have a senior that is explaining the coding stuff like this to you, leading you to evolve faster? I am missing this in our company. I am left on my own, but I could grow so much faster having somebody like Arjan giving me feedback 🥺
@ArjanCodes Жыл бұрын
Consider me your virtual mentor! :)
@LittleGnawer Жыл бұрын
Finally I know, where the word dunder comes from: "double underscored". 😀
@joekeenan2114 Жыл бұрын
Batman is DC, not Marvel. ;)
@DenisTrebushnikov Жыл бұрын
I've been confused too
@topcivilian Жыл бұрын
Using VS Code + iOS = telemetry
@rosyidharyadi7871 Жыл бұрын
I've known python for years but just realizing dunder stands for double underscore. Not a native, so I thought it was a real English word.
@BrigetteVazquezSegoviaАй бұрын
great video ! but batman is not part of marvel !!!
@RealLexable Жыл бұрын
Are your video titles AI generated, or why am i so confused eveytime clicking on a german title but hearing english at the end? 😅
@ArjanCodes Жыл бұрын
Yes, I included translations in 6 languages to provide more accessibility.
@Bakobiibizo Жыл бұрын
lol batman is DC
@maksimon519 Жыл бұрын
dunder methods are just builtin protocols. thats it.
@addcoding8150 Жыл бұрын
I don't know why you translate your stuff with ai, but the translations are hilariously wrong. Just stop it, it's embarrassing.
@franktewierikholscher Жыл бұрын
I agree. Dunder is translated in dutch with: dollar, donor, donna and sometimes even with dunder 😂😮
@inopsek Жыл бұрын
Agree, doesn't bring anything.
@cezartorescu Жыл бұрын
Yea! Another example of why not to rely on the dumb ai ...
@ArjanCodes Жыл бұрын
I'm trying to provide more accessibility; however, it's not possible for me to manually translate each video.
@addcoding8150 Жыл бұрын
@@ArjanCodes That's totally understandable. But you ain't increasing accessibility when the translations are grammatically and semantically wrong. I'd rather have 0 subs than wrong subs