Python 3 - The Wonderfully Simple Reduce Function

preview_player
Показать описание
In this session we'll look at the reduce function, which is a function that comes from the functools module.

My beginners Python course:

My functional Python course:

-------------
GET The Pythonistas Notebook as your learning companion!
--------------
--------------
JOIN for in-depth coding videos!
------------
Python 3 is an incredible language for beginners, and in each of these videos I am to bring a simple idea to you in short and easy to digest videos. I will be covering data types, control flow, looping, functions, comprehensions, variables, object orientation and much more.
------------
Have a request? Drop me a message!
Рекомендации по теме
Комментарии
Автор

While you explained the mechanism, i think the examples given were better served by sum(《list》) and reversed(《string》) or slicing or sorted(). You say you use this every day, perhaps a real world example or examples following this explanation of the mechanism would be more helpful than the toy examples alone.

cainepeter
Автор

“and then, finally, the ‘d’ comes in”… my highschool self was giggling 🤭😂

hanspeterfake
Автор

Although well presented, I'm not impressed with the value of reduce(). I cannot think of a use case where the same thing cannot be accomplished with one of the simpler functions, such as sum(), max(), min(), any(), all(), etc. Perhaps this is why it's no longer a built-in function.

kenhaley
Автор

The functions you demonstrated in combination with reduce are basically just sum and reversed, so you don't show any real value for it.

theoriginalneckbeard