Python Forum
Code golfing: splitting a list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Code golfing: splitting a list
#1
Question 
So I have a list L. To do some parallel processing, I want to split it into N sublists of equivalent length. The contents of the sublists are indifferent. What is your shortest and/or most pythonic code? Can you avoid using len(L) explicitly? 

python python python
Unless noted otherwise, code in my posts should be understood as "coding suggestions", and its use may require more neurones than the two necessary for Ctrl-C/Ctrl-V.
Your one-stop place for all your GIMP needs: gimp-forum.net
Reply


Messages In This Thread
Code golfing: splitting a list - by Ofnuts - Jan-11-2017, 10:04 PM
RE: Code golfing: splitting a list - by ichabod801 - Jan-12-2017, 01:26 AM
RE: Code golfing: splitting a list - by Ofnuts - Jan-12-2017, 08:10 AM
RE: Code golfing: splitting a list - by Mekire - Jan-12-2017, 02:41 AM
RE: Code golfing: splitting a list - by wavic - Jan-12-2017, 09:13 AM
RE: Code golfing: splitting a list - by Ofnuts - Jan-12-2017, 11:33 AM
RE: Code golfing: splitting a list - by ichabod801 - Jan-12-2017, 10:50 PM
RE: Code golfing: splitting a list - by wavic - Jan-12-2017, 11:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  "pythonic" way of splitting up my code? liggisten 4 835 Dec-30-2023, 08:23 PM
Last Post: Gribouillis
  Splitting code into several files TLammert 4 1,577 Jun-26-2022, 02:33 PM
Last Post: TLammert
  Splitting strings in list of strings jesse68 3 1,892 Mar-02-2022, 05:15 PM
Last Post: DeaD_EyE
  Splitting String into 2d list cclark135 2 2,885 Aug-26-2019, 01:46 PM
Last Post: ThomasL
  splitting numeric list based on condition python_newbie09 7 9,651 May-27-2019, 03:58 PM
Last Post: python_newbie09
  Need help | splitting list into list Vinci141 3 2,675 Mar-13-2019, 09:09 PM
Last Post: Vinci141
  some ideas for intelligent list splitting? wardancer84 4 3,293 Nov-20-2018, 02:47 PM
Last Post: DeaD_EyE
  Splitting a list help johiah 5 4,849 Mar-21-2017, 04:31 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020