MIXINS in Python explained with an example

Поделиться
HTML-код
  • Опубликовано: 4 дек 2024

Комментарии • 11

  • @Raisincookies55
    @Raisincookies55 29 дней назад

    short and to the point. great work

  • @EmadRahman_eee
    @EmadRahman_eee Год назад +1

    Thank you very much for the video.

  • @Иван-д6ф6с
    @Иван-д6ф6с Год назад

    Great!

  • @bomthanhha
    @bomthanhha Год назад

    I think dependency injection to achieve the same thing without using inheritance. For example, I can assign self.serializer = Serializer() at def __init__(). Am I thinking correctly? When should I decide to use dependency injection vs mixins and vice versa?

    • @python-for-everyone
      @python-for-everyone  Год назад

      Dependency injection is the technique to inject objects into other objects. Could it be you mean when to favor composition over inheritance? In this video, I show a scenario where DI and composition work very well: ruclips.net/video/BdMO1IR-800/видео.html

  • @Иван-д6ф6с
    @Иван-д6ф6с Год назад

    Can you make video abou SOLID principles?

    • @python-for-everyone
      @python-for-everyone  Год назад

      Here is a youtube video: ruclips.net/video/VqeBgD5TuAQ/видео.html on the Open Closed Principle and if you want to support me, you can enroll in my S.O.L.I.D. course on Udemy: pythonforeveryone.com/python-solid-online-training.html

  • @TomasHayes
    @TomasHayes 11 месяцев назад

    I'm struggling with IDE typing errors when a mixin access to properties it doesn't posses (yet).
    Any advice on how to handle that properly? Thank you!

    • @python-for-everyone
      @python-for-everyone  11 месяцев назад

      Yep, that is a problem of dynamically typed languages. There is no guarantee that attributes will be present. If you want to satisfy the type checker, you could use base classes or protocols.