Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reduce nested for-loops
#2
The code doesn't look awful to me. But you want to do something for each "d", and those are nested way down inside a hierarchical datastructure. If you need to do this with any frequency, the items should be more accessible.

In isolation, it's hard to make suggestions. But perhaps you should instead have a collection of objects, each of which has the "b", "c" and "d" information. Then you can just iterate over that collection.

So I'd focus on the data and the data layout, not the specific set of loops shown.
Gribouillis likes this post
Reply


Messages In This Thread
reduce nested for-loops - by Phaze90 - Mar-14-2023, 08:34 PM
RE: reduce nested for-loops - by bowlofred - Mar-14-2023, 09:24 PM
RE: reduce nested for-loops - by Phaze90 - Mar-16-2023, 09:26 AM
RE: reduce nested for-loops - by DeaD_EyE - Mar-15-2023, 11:30 AM
RE: reduce nested for-loops - by bowlofred - Mar-15-2023, 02:35 PM
RE: reduce nested for-loops - by Phaze90 - Mar-16-2023, 09:20 AM
RE: reduce nested for-loops - by deanhystad - Mar-15-2023, 04:48 PM
RE: reduce nested for-loops - by DeaD_EyE - Mar-16-2023, 09:23 AM
RE: reduce nested for-loops - by DeaD_EyE - Mar-16-2023, 10:56 AM
RE: reduce nested for-loops - by jefsummers - Mar-16-2023, 04:22 PM
RE: reduce nested for-loops - by deanhystad - Mar-16-2023, 04:30 PM
RE: reduce nested for-loops - by ndc85430 - Mar-16-2023, 06:28 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding values with reduce() function from the list of tuples kinimod 10 3,075 Jan-24-2023, 08:22 AM
Last Post: perfringo
  Nested for loops: Iterating over columns of a DataFrame to plot on subplots dm222 0 1,889 Aug-19-2022, 11:07 AM
Last Post: dm222
  Nested for loops - help with iterating a variable outside of the main loop dm222 4 1,812 Aug-17-2022, 10:17 PM
Last Post: deanhystad
  breaking out of nested loops Skaperen 3 1,374 Jul-18-2022, 12:59 AM
Last Post: Skaperen
  Break out of nested loops muzikman 11 3,668 Sep-18-2021, 12:59 PM
Last Post: muzikman
  How to break out of nested loops pace 11 5,694 Mar-03-2021, 06:25 PM
Last Post: pace
  Nested for Loops sammay 1 12,142 Jan-09-2021, 06:48 PM
Last Post: deanhystad
  How do I reduce the time to Invoke Macro via Python? JaneTan 1 2,270 Dec-28-2020, 06:46 AM
Last Post: buran
  How to reduce the following code to run in sequence? Giggel 4 2,815 Jun-28-2020, 01:31 AM
Last Post: Giggel
  How to make this function general to create binary numbers? (many nested for loops) dospina 4 4,695 Jun-24-2020, 04:05 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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