howto handle nested for

N

Neal Becker

I know this should be a fairly basic question, but I'm drawing a blank.

I have code that looks like:

for s0 in xrange (n_syms):
for s1 in xrange (n_syms):
for s2 in xrange (n_syms):
for s3 in xrange (n_syms):
for s4 in range (n_syms):
for s5 in range (n_syms):

Now I need the level of nesting to vary dynamically. (e.g., maybe I need to add
for s6 in range (n_syms))

Smells like a candidate for recursion. Also sounds like a use for yield. Any
suggestions?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,082
Messages
2,570,588
Members
47,209
Latest member
Ingeborg61

Latest Threads

Top