Total combinations from a variable set of lists using itertools I am using python and I believe the problem below can be solved using itertools but if there is another method please let me know.  If I have a variable set of lists (for illustration purposes let it be 3) and each contains a variable set of elements (elements could be strings, integers, lists).  An example:                            [a,b,c]   [d,e,f]   [g,h,i]   How can I create (and access) all the total possible combinations (as a list preferably) choosing just one from each set?  i.e.   [a,d,g]  [a,d,h]  [a,d,i]  [a,e,g]  ... (and so on)  Order does not matter so for the output I do not want [a,d,g] and [d,a,g] both to show, just [a,d,g].  If my question is not clear please let me know.   Also, if it helps we can consider all elements to be simple strings or integers but I would like a solution that takes in count the fact that the number of lists and the number of elements in each list is variable.
Get the cartesian product of a series of lists? How can I get the Cartesian product (every possible combination of values) from a group of lists?  Input:   somelists = [    [1, 2, 3],    ['a', 'b'],    [4, 5] ]   Desired output:  [(1, 'a', 4), (1, 'a', 5), (1, 'b', 4), (1, 'b', 5), (2, 'a', 4), (2, 'a', 5) ...]
So this has been an on-going saga the last few days, and I've already posted several related questions here, and I am feeling quite defeated.  I have/had a beautiful 16" cast iron dutch oven from Cabelas. I took it out for a test spin the other night (I had completed all seasoning steps that the Google Gods recommended). Then:   I tried (and failed spectacularly) to cook a pork roast in it, but cooked it at way too hot a temperature and burned/charred/fused the animal fats/juices into the oven, whereby it basically baked into the cast iron (related question ) I tried cleaning/scrubbing it with coarse-grained salt -> did nothing Then I tried cleaning it with dishwashing liquid + salt -> did nothing Then I let the whole thing soak in a vat of a 50/50 mixture of water + white vinegar -> took all the tarry slude off, stripped some seasoning off (revealing bare iron), but in 80% of the burned/charred areas, still did nothing Then I went to town on it with a steel wool and salt and dishwashing liquid and was left with some smooth, properly seasoned surfaces, and some more areas stripped down to bare metal I decided to just re-season it. So I scrubbed it one last time (about 1 hour ago) with a steel wool and some water, got all the rust and remaining crud off (finally), and built a fire. I placed it on the hot coals of the fire and let it sit there for 15 mins. My intention (whether misled or not) was to burn off all the remaining water from when I had previously washed/scrubbed it, then let it cool off, then season it with oil, and then bake it for a few hours.   So I just took the oven off the fire and opened the lid...and the entire inside is covered in rust. An hour ago there was none. When I put the oven into the fire 15 mins prior, there had been none (yes, I checked) This just came out of nowhere.  I'm ready to give up, unless anyone can offer some concrete set of steps for me that will salvage this $100 rust bucket. How can I get rid of the rust and then re-season this before more rust sets in? Meh... What are the differences between "to talk" and "to speak"? Both verbs "to talk" and "to speak" refer to the same action.  Is their meaning exactly the same? When is more appropriate to use one, or the other verb? How safely bring lamp wire into house? I'm considering replacing an outdoor lighting fixture with an LED motion-sensitive fixture, but I'm not sure how to safely do the wiring.  The location is protected (under a porch) but still needs to be weatherproof. Here's the existing fixture and mount:    The obvious replacement would be another lamp that included its own box cover, so that its wiring would be covered and protected. But, the fixture I like doesn't include such a cover:    You can see it's meant to be screwed into the wall, but doesn't cover anything. The power cable ends with bare wires which are meant to be wire-nutted to the supply wiring, probably inside a junction box. But, how do I get the wire safely into the junction box while keeping things weatherproof?  One option would be to replace the lamp's power cable with one ending in a grounded plug, and install a weatherproof outlet box. But that's ugly and complex.  Are there weatherproof junction box covers that include provisions for sealed entry of cables? What is the best way to initialize a private, static data member in C++?  I tried this in my header file, but it gives me weird linker errors:  class foo {     private:         static int i; };  int foo::i = 0;   I'm guessing this is because I can't initialize a private member from outside the class.  So what's the best way to do this? What is the typical orbital life of an artificial satellite? The orbit of satellites around Earth eventually decays, or so I read. This is typically caused either by atmospheric drag, or by tides. I would assume most satellites have a limited service life in orbit. Hence the question - What is the typical orbital life of a satellite? How long before it's successor must be launched into orbit ?  EDIT: For instance, a weather satellite Add anchors to the how-to-ask and how-to-answer pages I have three partitions on my drive, arranged something like the following:   ___________ | 1 |  2 | 3| -------------   I wish to merge partitions 1 and 3.  Is there a way to do this, or do I have to manually "slide" partition 2 over to partition 3, and then merge the newly open space where partition 2 used to be?  Note: I do not have the space to copy partition 2 to partition 3 (2 is 200GB and 3 is 65GB). I know it existed as sort of a folder in Windows Explorer in at least Windows XP, but I just can't seem to find it in Windows 7...  How can I take a picture with my webcam in Windows 7 without using any 3rd party tools? Initializing K-means centers by the means of random subsamples of the dataset? If I have a certain dataset, how smart would it be to initialize cluster centers using means of random samples of that dataset?  For example, suppose I want 5 clusters. I take 5 random samples of say, size=20% of the original dataset. Could I then take the mean of each of these 5 random samples and use those means as my 5 initial cluster centers? I don't know where I read this but I wanted to know what you guys think about the idea.    UPDATE: Please see this thread  for the general discussion about the various initialization methods. Maclaurin series of $\ln(1-x+x^2)$ Is there a closed form expression for $\text{n}^{\text{th}}$ coefficient of Maclaurin series of  $$\ln(1-x+x^2)$$ Note: this is intended to be a canonical question about summoning sickness.  "Summoning sickness", broadly, is the rule that stops you from attacking or paying {T} costs with a creature that you just played. But how exactly does it work? How does it interact with other rules and effects?  For example, if I'm trying to figure out how a creature is affected:   Does the status matter (tapped/untapped, face down/face up, etc.)? What if it came into play, but I didn't cast it? What if it's a token? What if it was on the battlefield when my turn started, but it wasn't a creature? What if it stops being a creature? What if it's a creature and also another card type? What if it's a double-faced card that just transformed? What if it changes control? What if it's a copy of another creature? Which of the creature's activated abilities can I use? Are any of its other abilities affected? Can I tap the creature to pay a cost that is not a {T} cost?   (These examples are primarily taken from questions about summoning sickness that have already been asked on the site) What is the best way to deal with very complex forms? I'm trying to give the best experience to users of a very huge system (like a CRM). It has a lot of forms and much of these have a lot of fields. My doubt is about if I should use a single column form (which raises too much vertical scrolling), or a two columns form (which needs less vertical scrolling and uses more horizontal white space) and a last one with four columns (which has few scrolling and uses almost whole white space to try to keep most of the fields above the fold).  It's important to say that our clients hate scrolling, and they always ask why we don't use the horizontal white space when we present a one column form).  So I'm little bit confused about it, because a lot of UX studies and good practices recommend to do not use/avoid multicolumn forms but the clients most of times ask multi column forms.  Our clients are very used to desktop programs and not everybody is very familiar with web based systems.  Below follows some possibilities I would like to share to illustrate an example of a complex form in the system with the three possibilities I mentioned:    In the example above I'm using the one column form (most recommended in UX studies), but with a very long vertical scroll.    In the second example I tried to reduce vertical space by using two columns.    This is the client's favorite one, 4 columns using white space and trying to keep everything above the fold.   The lengths of fields are based on the average of characters amount for each field.   I would like to know your opinion about the best approach to this case. Batch export Photoshop layers to individual PNG files I'm not sure which of the following sentences is correct. Is the comma mandatory, optional or unnecessary? I've googled a bit about this topic, but I got confused.     Our mapping contains 2000 words, which map to more than one lemma.   or     Our mapping contains 2000 words which map to more than one lemma.   Context: In total, there are more than 2000 words.  I've read  . If I understand the answers correctly, my "which map to more than one lemma" is a defining clause and no comma is required. But is it wrong to add one? What is the difference between \emph{...} and {\em ...}?  When to use each of them? Initialize parameter of method with default value Let $G$ be abelian, $H$ and $K$ subgroups of orders $n$, $m$. Then G has subgroup of order $\operatorname{lcm}(n,m)$. How would I implement a realistic stock market? Horned Mohawk looking insect. What is it? Any ideas? I didn't know any other way to explain it.  I live in Indiana, USA if that helps.   Someone said it might be a "stink bug" but I'm not sure and not willing to find out! Why does input capacity of an opamp increase noise gain? On the image below you can see an inverting amplifier with input capacity C1 and capacity C_F for general stability.     Now my book shows me following frequency plot:  A_n ... Noise-Gain  A_D ... open-loop gain  A_U ... V_out / V_in --> inverting amplifier gain     You can clearly see that C1 is increasing the noise gain at some point. And C_f is stabilizing A_n and A_U.   But why exactly does C1 increase the noise gain exactly?