Day 9 of 100 Days

Day 9: 2018/05/04

Today’s Topic: Python – General topics.

Today’s Progress: As I wrote yesterday, I would like to revisit a few topics, and today I went through:

  • Lambda, filter, map, reduce

Thoughts: I didn’t know reduce is now moved to module functools, and I just learned it today. There are always new things happening all the time. (Maybe not new, but new to me.) I also noticed a good site for beginners: python course, where I think they explain some topics better (or at least in more detail) than “A Byte of Python”. There are things I that I still don’t quite get in the map part, but I think the list comprehension should solve that problem.


  • lambda args_list: expression
  • r = map(func, seq) → returns an iterator
  • map can handle more than one seq (with lambda):
    map(lambda x, y: x + y, seq1, seq2)
  • the above returns an iterator, before you use it, do new_list = list(iterator) and use that.
  • map can handle sequences with different length. The operation stops at the shortest length.
  • map can apply to “functions” as well
  • A lot of times (if not all the times), this can be written as list comprehension
  • list comprehension [x for x in something]
  • set comprehension (to avoid duplicates) {x for x in something}
  • decorator → @, func to modify a property of a function.

Link to work: Link to my own Google drive to show my progress here.

This entry was posted in 象哥的學習筆記 Study Notes and tagged . Bookmark the permalink.

Leave a Reply