howto handle nested for
Neal Becker
ndbecker2 at gmail.com
Fri Sep 28 11:52:36 EDT 2012
More information about the Python-list mailing list
Fri Sep 28 11:52:36 EDT 2012
- Previous message (by thread): howto handle nested for
- Next message (by thread): howto handle nested for
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Neal Becker wrote: > 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? Thanks for the suggestions: I found itertools.product is just great for this.
- Previous message (by thread): howto handle nested for
- Next message (by thread): howto handle nested for
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list