How To Split Any List Into Equally-Sized Chunks (Python Recipes)

Поделиться
HTML-код
  • Опубликовано: 4 сен 2024

Комментарии • 21

  • @anon_y_mousse
    @anon_y_mousse 2 месяца назад +5

    Neat, now everyone can do it from the standard library. I still wish they'd implement the interface the way I did. I overloaded division on lists and strings to allow dividing them into specifically sized chunks. I even overloaded the modulus operator so you could siphon off any oddball chunk. I should probably post it up somewhere because I really think others should copy my method here.

    • @joeystenbeck6697
      @joeystenbeck6697 2 месяца назад +1

      This is such a good idea. You should totally post it! Maybe there could be list.batch too. Or, iterator.batch (so it doesn't just work for lists). I could see division as meaning only giving a single chunk, that is 1/n times the size of the original list. I haven't thought about it too much though. I don't see many use cases for the single chunk 1/n idea and I see a lot of use cases for your idea so I think your idea is probably much more useful. Plus many operators are near what they would intuitively mean rather than exactly what they intuitively mean so.

  • @python_n_c
    @python_n_c 2 месяца назад +2

    Ironically needed this method this week lol. Great video!

  • @pseudotasuki
    @pseudotasuki 2 месяца назад +2

    Could you do a video about Micropython? I'm using it on a project and found it to be pretty impressive.

  • @MuhammadFaizanMumtaz3
    @MuhammadFaizanMumtaz3 2 месяца назад +2

    Your doing so great❤.

  • @dipeshsamrawat7957
    @dipeshsamrawat7957 2 месяца назад +1

    01:21 Also a comprehensive video on generators.

  • @diogolscc
    @diogolscc 2 месяца назад

    the fact that i literally needed this

  • @rishiraj2548
    @rishiraj2548 Месяц назад

    Great thanks

  • @krzysiekkrzysiek9059
    @krzysiekkrzysiek9059 2 месяца назад

    That short tips are the best 👍

  • @twindrawingstudio
    @twindrawingstudio 2 месяца назад +1

    Thanks 🎉🎉

  • @chrism6880
    @chrism6880 2 месяца назад

    Is there any good reason to type annotate a variable that is being initialized with data? Pydantic already knows the expected type of the object you're assigning to the variable.

  • @user-ro4oc6qb5g
    @user-ro4oc6qb5g 2 месяца назад

    Actually, after execution we got tuple as 9 alone.. In this case what should we do when came up with (9,0). 0 represents the non value when splitting it.

  • @oneil-levyebangmbaa933
    @oneil-levyebangmbaa933 2 месяца назад +1

    Awesome 😅

  • @robertwilliam865
    @robertwilliam865 Месяц назад

    Isn't this the merge sort method ?

  • @MuhammadFaizanMumtaz3
    @MuhammadFaizanMumtaz3 2 месяца назад

    I have created a separate folder for this amazing series.

  • @rishiraj2548
    @rishiraj2548 2 месяца назад +1

    🙏🏻🙂👍🏻

  • @aub2433
    @aub2433 2 месяца назад

    How to make telegram group shilling bot? Did you make any tutorial, if not,
    Can you please make one?
    Can we use botfather to make a shilling bot?
    Thank you

  • @ukrainianmaps1573
    @ukrainianmaps1573 2 месяца назад +1

    hi