I have a list : lst = [('asd'),('fgb'),('tre'),...] like this . I want to remove "(" and ")" characters . The result must be : ['asd','fgb','tre',...]
Is there a simple way to flatten a list of iterables with a list comprehension, or failing that, what would you all consider to be the best way to flatten a shallow list like this, balancing performance and readability?  I tried to flatten such a list with a nested list comprehension, like this:  [image for image in menuitem for menuitem in list_of_menuitems]   But I get in trouble of the NameError variety there, because the name 'menuitem' is not defined.  After googling and looking around on Stack Overflow, I got the desired results with a reduce statement:  reduce(list.__add__, map(lambda x: list(x), list_of_menuitems))   But this method is fairly unreadable because I need that list(x) call there because x is a Django QuerySet object.  Conclusion:   Thanks to everyone who contributed to this question.  Here is a summary of what I learned.  I'm also making this a community wiki in case others want to add to or correct these observations.  My original reduce statement is redundant and is better written this way:  &gt;&gt;&gt; reduce(list.__add__, (list(mi) for mi in list_of_menuitems))   This is the correct syntax for a nested list comprehension (Brilliant summary !):  &gt;&gt;&gt; [image for mi in list_of_menuitems for image in mi]   But neither of these methods are as efficient as using itertools.chain:  &gt;&gt;&gt; from itertools import chain &gt;&gt;&gt; list(chain(*list_of_menuitems))   And as @cdleary notes, it's probably better style to avoid * operator magic by using chain.from_iterable like so:  &gt;&gt;&gt; chain = itertools.chain.from_iterable([[1,2],[3],[5,89],[],[6]]) &gt;&gt;&gt; print(list(chain)) &gt;&gt;&gt; [1, 2, 3, 5, 89, 6]
Does the closedness of a subgroup $H$ of $G$ imply that for $h\in H, g\in G \setminus H : hg \not \in H$? Does the closedness of a subgroup $H$ of $G$ imply that for $h\in H, g\in G \setminus H: hg \not \in H$?  I'm new to abstract algebra and this would appear to be a useful result. However, by definition, a subgroup is nearly closed, and I don't think this directly implies that for any element $g$ from $G$ not in $H$, the composition $gh \not \in H$.  Is this in fact a true statement? I read this quite a while back, part of my parents library (they're in their 50s now) I think the book was probably published in the 70s or 80s, my copy was paperback. I don't recall the cover art, but I have vague recollections of a satellite on the cover and maybe blue with grid-lines below it?  I've made concerted efforts to find it again but to no avail. My parents don't remember it either, but mum's an avowed book-aholic and buys a lot of books, reads them once and forgets about them, so that's not so surprising.  The key parts I remember:   Both the Soviets and Americans were working on psychic techniques and technologies, with real and tangible results including Remote Viewing. MK-ULTRA was explicitly namedropped in relation to the American psychic program. The Soviets and Americans both had orbiting superweapons, One was a microwave laser (or something very similar) and the other used slivers of the brains of psychics to blow people's brains up in a wide area. A super-psychic (male) took offence to the state of the cold-war and took control over the orbital weapons by manipulating the onboard computers psychically. There's a gruesome description of a psychic weapon being tested on monkeys in a lab, the POV character throws up afterwards in horror. I think there might have been more than one POV character. There's an extended description of the psychic orbital weapon as experienced by people in its area of effect. Similar to the monkeys, it builds up, starting with alzheimer-esque hand-shaking and building up to seizures and screaming before their brain liquifies fully and either comes out the nose and ears or outright blows the skull open. (this is one of the more vivid recollections I have of the book) I remember that the super-psychic was working wholly alone and did most of his psychic stuff from motels halfway around the world from events. I believe the super-psychic also killed other psychics explicitly. The weapon satellites had code-names Both weapons were used on cities in the course of the story I vaguely recall an office building getting targeted specifically at one point. How do you convert LPCWSTR to const char *? restrict 1 word as case sensitive and other as case insensitive in python regex | (pipe) How can adding an infinite number of rationals yield an irrational number? For example how come $\zeta(2)=\sum_{n=1}^{\infty}n^{-2}=\frac{\pi^2}{6}$. It seems counter intuitive that you can add numbers in $\mathbb{Q}$ and get an irrational number. The question Is there any way to automatically scale and put an entire document on an A0 page? The thesis for which this is to be done is available as LaTeX code, as well as PDF output. Of course I know it is possible to do this manually, but I would prefer a LaTeX solution.  A small background Our university introduced a new page limit for master theses. This is not exactly appreciated by the teaching staff as well as students. To make a little joke, we decided to try to arrange an entire thesis (of approximately 200 pages) on a A0 poster, put it up in the hallway, and put a magnification glass next to it with a note saying: &quot;New page limit introduced: 1 page maximum for all upcoming theses!&quot;  The final result As some of you asked for this: below you can see a picture of the final result. (I &quot;professionally removed&quot; some of the sensitiv information.) We presented the poster during my final presentation and everyone liked it a lot! Now, it is on display next to my office and is still attracting some attention once in a while. In film reviews/essays about a book or film, does the title of the movie/book always have to be highlighted/put in italics? I want to find a formula for the sum of this series using its general term. How to do it?  Series $$ S_n = \underbrace{1/3 + 2/21 + 3/91 + 4/273 + \cdots}_{n \text{ terms}} $$  General Term  $$ S_n = \sum_{i=1}^{n} \frac{i}{i^4+i^2+1} $$ Why the switch statement cannot be applied on strings? Compiling the following code and got the error of type illegal.  int main() {     // Compilation error - switch expression of type illegal     switch(std::string("raj"))     {     case"sda":     } }   You cannot use string in either switch or case. Why? Is there any solution that works nicely to support logic similar to switch on strings? Short Story About Contact With An Alien Race That Extruded An Elixir If the Universe is expanding, how is that galaxies run into each other? As the title says. If everything is moving outward, thrown by the Big Bang, how could two Galaxies end up with velocity vectors that run them into each other? Selection by attribute string with wildcard as part of name in ArcGIS Desktop? I have an attribute field in my file geodatabase (GDB) where I'm trying to select all records that contain an underbar in the string field.  The issue is that the underbar is considered a SQL wildcard on its own.  To illustrate: I need all data similar to "ID" = '42W_42_42E' or "ID" = '31A_31'  Using "ID" LIKE '%_%' returns all records, which isn't helpful.  The perfect solution would simply return a count on the number of records with the underbar in their ID attribute. The "Hurry up, it's raid night" achievement in Starcraft 2 involves "beating Wings of Liberty, on normal, in 8 hours or less."  Is there a recommended mission path to take? Which mission should I take for the branching paths? Does it count time spent on the Hyperion in between missions, or is it exclusively time elapsed on missions. Does replaying a mission affect the time? General tips / hints from those who've unlocked the achievement?  Edit: Just got this achievement tonight, finally! The answer was perfect. Workflow email with link to document in library How to fix "Duplicate sources.list entry" warning? Every time I try to do some update (sudo apt-get update) it says:   Reading package lists ... ready W: Duplicate sources.list entry http://archive.canonical.com/ubuntu/ need /partner amd64 Packages (/var/lib/apt/lists/archive.canonical.com_ubuntu_dists_precise_partner_binary-amd64_Packages) W: Duplicate sources.list entry http://archive.canonical.com/ubuntu/ need /partner i386 Packages (/var/lib/apt/lists/archive.canonical.com_ubuntu_dists_precise_partner_binary-i386_Packages) W: You have to run apt-get update to correct these problems   sources.list:   ls /etc/apt/sources.list.d/ as requested:  milton@milton-HuronRiver-Platform:~$ ls /etc/apt/sources.list.d/ emesene-team-emesene-stable-precise.list precise-partner.list precise-partner.list.save upubuntu-com-chat-precise.list upubuntu-com-chat-precise.list.save Find the limit of $\frac{n^{x}}{(1 + x)^{n}}$ Let $x&gt;0$. Find $$\lim_{n\to\infty}\frac{n^{x}}{(1 + x)^{n}}.$$   What I was thinking involved an inequality, by reason of considering the fact that  $$(1 + x)^{n} &gt; C(n, k) x^{k}$$ for some $k$ such that $n&gt;k$. Expanding the binomial coefficient and taking the $n$ common from each bracket, we have something like $$(1 + x)^{n} &gt; C(n, k) x^{n} &gt; \frac {x^{k}n^{k}}{k! 2^{k}}.$$ But now, I am totally clueless. By intuition, I know that the limit has to be zero, so I just want to prove using the concept of inequalities that what I thought was the right approach (being the sandwich theorem). Any help would be appreciated! How can I attach a file to a question? I want to attach a code file to my question, but I am not able to find a link to do it. Is attaching files possible at all? At the end of the game, how are medals awarded?   As a secondary, what is the relation between bronze silver and gold medals, and how much experience do they reward? How to prove that this set is closed? Suppose $Y$ be an ordered set in the order topology. Let $f, g: X \to Y$ be continuous. How to show that the set $\{x| f(x) \leq g(x)\}$ is closed?  This is a excercise from munkres. Maybe trying to show that the set $f(\{x| f(x) &gt; g(x)\})$ is open is suffice. But I could not figure out the connection between this set and the continuity of the two functions.Could you give a hint?  Thanks. List of apps ever downloaded