5 Useful Iterator Functions in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 3 ก.พ. 2025

ความคิดเห็น •

  • @Kob_e_
    @Kob_e_ 8 ชั่วโมงที่ผ่านมา +4

    5:41 (as far as I know) mathematically, the correct term is “permutations”, not “combinations”. Combination doesn’t care about order (meaning, ‘AAB’ is the same as ‘ABA’ and ‘BAA’). Just wanted to point that out 😅
    edit: you really saved the best for last, starmap and groupby both sound really useful! Thanks for this!

  • @warszafication
    @warszafication 4 ชั่วโมงที่ผ่านมา +1

    Itertools... Back in the day, it was a revelation for me...

  • @Diegos79
    @Diegos79 8 ชั่วโมงที่ผ่านมา

    groupby is a powerful function!

  • @CwMuller
    @CwMuller 2 ชั่วโมงที่ผ่านมา +1

    I feel you skipped over what i consider to be the best feature of product(). It takes an arbitrary number of sequences as positional arguments, and will return all combinations of items in those sequences as a sequences of tuples. If you combine this with unpacking, you can avoid the typical antipattern of nesting for loops, with a single for loop.

  • @danielputter
    @danielputter 4 ชั่วโมงที่ผ่านมา

    Can zip_longest’s fillvalue be a tuple, such that each list will be “filled” with a correspondingly indexed value from the tuple?

  • @denki2558
    @denki2558 42 นาทีที่ผ่านมา

    Would have been better for groupby to just have a sort argument. That implementation does decorate, sort, undecorate, decorate, and group+undecorate, rather than decorate, sort, and group+undecorate.
    If the key is an expensive operation, you need to do the decorating yourself for performance.

  • @samoylov1973
    @samoylov1973 5 ชั่วโมงที่ผ่านมา

    Funny enough, in the word "funny" this groupby code will show us only one vowel sound. But everyone knows there are two vocal letters in this word ))