Python Forum

Full Version: Nesting loops more than 20
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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**
(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.
Yikes! this hurts my eyes!