Re: Behavior of the for-else construct

2022-03-04 Thread Om Joshi
I'm not sure if anyone has mentioned it on this thread, but with respect to your comment about adding either on.empty or a decorator, the Django template syntax uses {% for x in iterator %} {{ x }} {% empty %} Empty {% endfor %} and this seems to work quite well and be incredibly intuitive, a

Re: All permutations from 2 lists

2022-03-02 Thread Om Joshi
Something like this?itertools.product(x or ("",) for x in perm_elems)Out of curiousity, how might one adapt this if x is not a list but an iterator, without doing `itertools.product(list(x) or ("",) for x in perm_elems)`?  On Wed, 02 Mar 2022 09:25:42 -0600 antoon.par...@vub.be wrote

Re: All permutations from 2 lists

2022-03-02 Thread Om Joshi
I sent this 17hrs ago but I guess it just went through. Apologies for the redundant comments... On Tue, 01 Mar 2022 18:57:02 -0600 om+pyt...@omajoshi.com wrote For completeness, the itertools solution (which returns an iterator) is >>> os = ["Linux","Windows"] >>> region = ["us-east-

Re: All permutations from 2 lists

2022-03-02 Thread Om Joshi
For completeness, the itertools solution (which returns an iterator) is >>> os = ["Linux","Windows"] >>> region = ["us-east-1", "us-east-2"] >>> import itertools >>> itertools.product(os,region) >>> list(itertools.product(os,region)) [('Linux', 'us-east-1'), ('Linux', 'us-east-2'), ('Windows', 'u