Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Nesting loops more than 20
#1
I am upto creating a lookup table for a Human modelling software, Makehuman I have to translate its scale into real world metric scale for that I am creating lookup tables. It has 25 parameters that needs to be varied, I am using 25 nested for loops for that and store values finally in database SQlite .
Initially I got an exception: Too many statically nested blocks.
So to solve it I made a function for loop 2 to loop 19 and ran the code, I did not get the exception but my system got hanged when it was just computing the 11th loop.
Then I breaked the loop in even more parts, so it ran the whole code but the result in the database was not as I wanted ie, for every loop that was replaced by a function it was not computing it for all the values I wanted. I am sharing the links to my code please have a look and tell me how can I modify them.
https://github.com/RtjShreyD/Playing-wit.../works4.py -->This clearly shows what I want to do.
https://github.com/RtjShreyD/Playing-wit.../works5.py --->This hangs my system.
https://github.com/RtjShreyD/Playing-wit.../works6.py --->This does not give correct result in the database.

Please advise what can be done. **geek**
Reply
#2
(Oct-05-2018, 07:28 AM)RtjShreyD Wrote: It has 25 parameters that needs to be varied, I am using 25 nested for loops for that and store values finally in database SQlite .
No offense intended, but there is absolutely no way that this is the best way (or even a remotely acceptable way) to do this.

For starters I would suggest looking at the itertools library. You should be able to do something like generate all permutations of the needed variables and go from there.
Reply
#3
Yikes! this hurts my eyes!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Transform list or set regardless of nesting structure blubb 2 1,955 Mar-10-2020, 07:17 PM
Last Post: ibreeden
  Python script that recursively zips folders WITHOUT nesting the folder inside the zip umkc1 1 2,821 Feb-11-2020, 09:12 PM
Last Post: michael1789

Forum Jump:

User Panel Messages

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