PLEASE Learn This Underrated Python Feature...

Поділитися
Вставка
  • Опубліковано 25 січ 2025

КОМЕНТАРІ • 20

  • @TechWithTim
    @TechWithTim  10 днів тому +2

    Get private mentorship from me -> training.techwithtim.net

  • @JeffreyChadwell
    @JeffreyChadwell 6 днів тому +3

    Great video! I already knew about partials, but you showed a couple of things I didn't know partials could do.

  • @abcd_2000
    @abcd_2000 5 днів тому +19

    Just create a class and three methods. Pass 3 required params to the class constructor. Then call the method you need. Problem solved. No need to reinvent the wheel. You get native language support, it is easy to test, it is easy to understand and support

    • @rexsybimatrimawahyu3292
      @rexsybimatrimawahyu3292 4 дні тому +2

      Agree. This stuff feels like reinventing the wheel but the wheel is a square shaped

    • @MrDjoe43
      @MrDjoe43 3 дні тому

      I hate partial. The behavior is weird with forced kwargs. It can lead to weird bugs that aren’t obvious at first sight. If I’m forced to use functional approach for this kind of problem. Il do it with lambda or inner function.

  • @adityasinghi
    @adityasinghi 6 днів тому +2

    Why can't I just abstract classes instead of partials?

  • @FrostSpike
    @FrostSpike 21 годину тому

    And you managed to explain that without using the word "currying" even once!

  • @multigladiator384
    @multigladiator384 6 днів тому +1

    Why not just use if (elif) else when passing arguments ..Would come down to one function aswell. Also you could make yourself a decorator that does what partial does with like 3 lines of code. No need to import the module.

    • @AkimboOfficial
      @AkimboOfficial 6 днів тому

      Because it gets harder to debug if anything does wrong. you need to find the specific function call within your if/else statements. If you use partials you can easily see what default arguments are being passed into the function in one line, then you can step back to where you defined the function with all the default arguments that you are modifying using partial.

    • @Comonad
      @Comonad 4 дні тому

      Black box logic AND reinventing the wheel? That sounds like a fast way to get coworkers/contributers to hate you. You want to signal from the outside of the function as much as much information as possible about what is happening - by conditionally dealing with parameters inside of the function you’re building up a lot of complexity for something that could be solved trivially

  • @Wutheheooooo
    @Wutheheooooo 4 дні тому

    Hello Tim, I think if you have some C experience, you should do a video on C API of Python, it is very game changing.

  • @conceptrat
    @conceptrat 2 дні тому

    Wouldn't this generate some confusing error messages if you didn't pass required parameters that you didn't define in the partial or call?

  • @JayDee28
    @JayDee28 5 днів тому

    looks like sleek way to overload methods incl. constructors.

  • @dianpriyambudi
    @dianpriyambudi 4 дні тому

    Thank you ❤

  • @clementdato6328
    @clementdato6328 4 дні тому

    It doesn’t work well with typing.

  • @_Cfocus
    @_Cfocus 6 днів тому

    just refreshed mu subscription

  • @deepironforge5377
    @deepironforge5377 6 днів тому

    Too bad I'm not far along enough. I think it would be pretty interesting. One day though...

  • @ShafiulShafi-zd4im
    @ShafiulShafi-zd4im 6 днів тому

    Yeeeeeyyyy

  • @Lightshine21
    @Lightshine21 6 днів тому

    Unsual explain I don't like the way you explain nothing I get it you have to explain line by line otherwise I can't watch your video anymore