Functional Programming in Python: The "filter()" Function



► Leverage Python’s advanced features to improve the quality of your code

In this Python tutorial you’ll learn the basics of functional programming in Python and how to use the “filter()” function to transform data structures.

We’ll take the example data set represented with an immutable data structure from the previous video in this series, and then we’ll create a “filtered down” version of the same data using Python’s built-in filter function. “filter()” is one of the functional programming primitives or building blocks available in Python and it’s useful in a number of contexts.

Later in the video you’ll also see how the filter function relates to list comprehensions and generator expressions in Python and how using these is (arguably) more Pythonic that relying on plain “filter()” calls.

This is part of a series of Python functional programming tutorials that I’m recording so stay tuned for the next instalment.

Also, be sure to check out these associated articles if you want to dive deeper into the subject:

* Immutable Data Structures in Python:
*
* List comprehensions:

FREE COURSE – “5 Thoughts on Mastering Python”

SUBSCRIBE TO THIS CHANNEL:

* * *

► Python Developer MUGS, T-SHIRTS & MORE:

► PythonistaCafe – A peer-to-peer learning community for Python developers:

FREE Python Coding Tutorials & News:
» Python Tutorials:
» Python News on Twitter:
» Weekly Tips for Pythonistas:
» Subscribe to this channel:

Nguồn: https://benjaminjcohen.com/

Xem thêm bài viết khác: https://benjaminjcohen.com/cong-nghe/

18 Comments

  1. Best videos I’ve seen explaining the fundamentals of functional programming.

  2. Really nice tutorials, I have been experimenting a lot with functional programming (I highly recommend Elixir) and I think that the most important thing when you look at the code you are seeing terms, propositions and affirmations instead of the steps to solve a problem.
    Declarative programming style is the future! <3

  3. Appreciate the functional programming series! thanks!

  4. Scientist is a tuple already, a named tuple, so why put it in a tuple() function again to turn it into a tuple?

  5. what is the correct term for getting the data from an iterator – "materialise"??

  6. Bought Python Tricks book today! Learning was never this fun. Thanks so much Dan for inspiring and teaching us.

  7. 3:20. Me. Every ducking time i see this output

  8. I was calling Lambda as Lam-b-da. Now I know it's Lamb-da 😉

  9. What’s the difference between iterator and a generator? Don’t both of them use yield?

  10. Well mapped out delivery of content (no pun intended) and yes, I do now better understand listcomps and genexp. Thanks

  11. Simple and effective tutorial. Thank you 🙂

  12. Hi Dan, Thanks for posting these videos. They really help me to learn python. How can I Replace Strings based on column number in CSV? I mean if the value is 0 in column 2 i need to replace it with null?

  13. This series is going really well. Keep up the good work, Dan!

  14. Great video. Hoping that you will get into more complex uses of build-in functions like filter or even itertools.

  15. For booleans 'x' is preferable to 'x is True' according to pep8 (see the bottom of the "Programming Recommendations" section)

  16. Thank you for the great tutorial. I really appreciated and your clarification of "is True" being implied, and then leaving it in the code to better clarify what is happening.

  17. Dan, would be great if you could do a video on decorators, why we use them, a senario where you can show case the usage of decorator and what happens if you don't use them. Great videos. Thank you again for all the efforts. Super helpful.

Leave a Reply

Your email address will not be published. Required fields are marked *