Python's collections.abc | InvertibleDict

preview_player
Показать описание
Learn your ABCs!

CONTEST CURRENTLY CLOSED! Thanks for playing!

OFFICIAL CONTEST RULES:
2. YouTube is not a sponsor of the contest and viewers are required to release YouTube from any liability related to the contest.
3. Privacy notice: no personal data will be collected for this contest.
4. In order to enter, you must (a) be one of my subscribers, AND (b) make a top-level comment to the video including #pycharm somewhere in the comment.
5. The contest is free, there is no fee required to enter.
6. Winners will be chosen randomly 1 week after the date the video went live from all users who have entered and not been disqualified.
7. Each winner will be notified via a comment reply from me that details what prize was won (e.g. "Congratulations! You have won XYZ. Please email me."). I will ask the winner to contact me by email, and I will reply through email with a random token which must be posted as another reply to the winning comment from the winning account in order to verify account ownership and prevent fraud.
8. Each winner will have 72 hours to respond AND prove account ownership or their prize is automatically forfeited and another winner will be chosen.
9. A winner can only win 1 prize per contest.
11. You may not enter the contest if doing so would be a violation of any relevant federal, state, and local laws, rules, and regulations, including U.S. sanctions.

SUPPORT ME ⭐
---------------------------------------------------
Sign up on Patreon to get your donor role and early access to videos!

Feeling generous but don't have a Patreon? Donate via PayPal! (No sign up needed.)

Want to donate crypto? Check out the rest of my supported donations on my website!

Top patrons and donors: Jameson, Laura M, Dragos C, Vahnekie, Neel R, Matt R, Johan A, Casey G, Mark M, Mutual Information, Pi

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------

CHAPTERS
---------------------------------------------------
0:00 Intro
0:35 All the ABCs
2:28 Type hinting
4:03 Runtime Interface Checking
5:38 InvertibleDict
13:44 Outro
Рекомендации по теме
Комментарии
Автор

It took me so long to understand covariance and contravariance of type variables, and honestly I would love to see you explain it, just so more people understand how powerful of a concept it really is

tylerfusco
Автор

Excited for the 15 parts series j/k. Would love to see a discussion of covariance and contravariance for python, ty! Love #pycharm

problematque
Автор

After surveying many python instruction channels on youtube I can confidently sayths is the best channel to learn about interesting facets of python programming. Your content should be sponsored by somebody like Khan Academy or LeetCode. I am baffled that you do not have more subscribers. Thank you for all of your efforts!

davea
Автор

I've actually had a situations where an InvertibleDict would've been useful. And I'm glad typehints are optional. Great for when you're building something bigger or sharing code with others. But if I just want to get some data analysis code, it's great to not have to worry about all those intricacies. #pycharm

PraecorLoth
Автор

This channel has the best videos for serious programmers #pycharm

felipedidio
Автор

Every time I see you have posted, I just know there will be a high quality video on an advanced topic. Love that.

knut-olaihelgesen
Автор

Why would you use .register, even if you implement everything yourself? Is there any downside to inheriting and overriding everything?

vidhanio
Автор

For the interfaces commonly used in Python, it is very convenient to use the abc module. But as far as I know most of the time you only need to use Protocol to type hint duck type custom classes. #pycharm

Jason-bt
Автор

Your explanation of ABC's was very good, I didn't know you could register classes to be counted as instances of ABC's. That makes me interested in how that's accomplished under the hood. I look forward to your explanation of covarient and contravarient types. #pycharm

SamuelDavenport-hv
Автор

Actually, the part you omitted would be the most interesting to watch. I hope there will be a part 2 of this video.

lex_darlog_fun
Автор

I recently came across the exact situation you describe and found it quite unsatisfying to manually define two dicts that are inverses of each other. This is very elegant, thanks a lot! #pycharm

bolzenguido
Автор

A video on the typing module and some advanced use cases? Like annotating a mixin class?

knut-olaihelgesen
Автор

Hello, great video! One little thing: likely it would be more effivcient to cache the .inv method to avoid recreating the class each time one wants an inversely mapped element? Or am I missing something here? Best wishes!

matteolacki
Автор

I've been programming for a while and only this month had a reason to look up what covariance is for typing, it's pretty neat but I definitely understand why you glossed over that :P In general I prefer interfaces to this direct inheritance as many languages only support one parent class, but as Python is Python I do appreciate what they offer with the ABCs

kalelsoffspring
Автор

In your implementation, the constructor always copies reference to the forward argument, even if backward isn't given. This can lead to the strange behavior when you create InversibleDict from other mapping and mutate one of them. Furthermore, if the original mapping was immutable, you'll get an error. I suppose #pycharm won't highlight that kind of error.

PeterZaitcev
Автор

Typehinting and strict data thpe restriction are something really useful for any level of collaboration of project.

chndrl
Автор

Great video: Nice summary of the basic concept, sprinkled with interesting sidenotes (e.g. i didnt know about the convention for hidden arguments)! Deliberately won't write the hashtag to avoid lowering the chance for people who would make better use of the license than me. 😊

KappakIaus
Автор

'Hey, kids! Today we're going to learn the ABC! That's right, little TImmy, Abstract Base Classed!!'

AntonioZL
Автор

thanks again for keeping up with the intermediate-advanced Python videos. much appreciated. #pycharm

yolosaurusrex
Автор

People go crazy with type hinting. But seeing how #pycharm can use it to infer autocomplete suggestions is pretty slick!

EvanBerkowitz