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
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.
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.
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.
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
Get private mentorship from me -> training.techwithtim.net
thx tim😊
Great video! I already knew about partials, but you showed a couple of things I didn't know partials could do.
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
Agree. This stuff feels like reinventing the wheel but the wheel is a square shaped
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.
Why can't I just abstract classes instead of partials?
And you managed to explain that without using the word "currying" even once!
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.
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.
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
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.
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?
looks like sleek way to overload methods incl. constructors.
Thank you ❤
It doesn’t work well with typing.
just refreshed mu subscription
Too bad I'm not far along enough. I think it would be pretty interesting. One day though...
Yeeeeeyyyy
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