I have the following construction with a long list of around 100 if .. elif. Is there a way do handle this more elegantly in python?     if isinstance(scen_dep, Class1):         scen_deps[someEnum.class2].append('1')    elif isinstance(scen_dep, Class2):         scen_deps[someEnum.class2].append('1')    elif isinstance(scen_dep, Class3):         scen_deps[someEnum.class3].append('1')
I want to write a function in Python that returns different fixed values based on the value of an input index.    In other languages I would use a switch or case statement, but Python does not appear to have a switch statement.  What are the recommended Python solutions in this scenario?
Is it possible to tell a Valyrian steel sword from a very well crafted steel sword, by sight alone How to create a bootable Ubuntu USB flash drive from terminal? Is there any way to create a bootable Ubuntu USB flash drive from the terminal without using any third-party applications like , , ,  etc.  I tried to create a bootable Ubuntu flash drive with dd method,  sudo umount /dev/sdb sudo dd if=/path/to/ubuntu.iso of=/dev/sdb bs=1M   It creates files on the USB disk, but when I try to boot the USB disk it shows an Operating System Not Found error. Is there way to move one vertex and make another move with it proportionally? I'll try to explain in this gif. I am doing this manually in 2 steps - rotate, scale. And I select all vertexes. Is there instrument rotate them in one step or can I move one and make other move too? How to reconnect a logically disconnected USB device? Proving this can be done as follows: consider a finite group G and elements $g_i \in G$ for some integer $i$. Now consider $\langle g_i \rangle = \{g_i^n: n\geq 0\}$, a generator. It can be proved that $\langle g_i \rangle \leq G$ and that the order of $g_i$ is equal to the order of $\langle g_i \rangle$, so $|\langle g_i \rangle| \leq |G|$.  We can now use Lagrange's theorem which states that if $H \leq G$ then $|H|$ divides $|G|$ and we're done. But...  Is there a simpler way to prove this fact? Mavericks unusually high RAM usage I thought Mavericks was suppose to utilize RAM memory better, thus run smoother.  Running ML on Mac mini 2012, with 16GB RAM...always running smoothly even with over a dozen apps running.  Now, after installing Mavericks, my Mac is SLOW, eating up RAM like crazy! Looking over usage, of the 16GB of installed memory...on average it uses 10-14 GB RAM when barely running a few apps!!!   There is this kernel_task that is always running with over 1GB of RAM and most apps are not taking that much RAM, so what is using up all my RAM?! File cache? It shows very high in that new description, with about 1/3 of my total RAM Kolmogorov-Smirnov two-sample $p$-values I am using the Kolmogorov&ndash;Smirnov two-sample test to compare distributions, and I noticed a $p$-value is frequently reported as the test statistic. How is this $p$-value determined? I know it's the probability of obtaining a result at least as large as the one obtained, but how is this $p$-value determined given this is a nonparametric test? That is, we can't assume Gaussian fluctuations in the distribution and compute the $p$-value using a $t$-test.  Thanks! "Elder brother" or "older brother"? I've read both forms in newspapers and online news: elder brother and older brother. What's the difference between them? When should I use which? I don't know what exactly it's called, by cache refresh I mean, refresh the page after clearing its cache. I don't want to clear the entire browser cache.  I can't seem to cache refresh my pages. In Firefox, I know it to be Shift+Refresh.  In Chrome, I've tried Ctrl+R, Ctrl+Refresh, Alt+Refresh, Shift+Refresh but none of them work. Solve $$u_{xx}-3u_{xt}-4u_{tt}=0$$ where $u(x,0)=x^2$ and $u_t(x,0)=e^x$.  My workings so far: I have factored the differential equation in the following way: $$(\delta_x-4\delta_t)(\delta_x+\delta_t)=0$$ where $\delta_x=\frac{\delta}{\delta x}$ etc. Now if we let $v$ be the solution to $(\delta_x+\delta_t)u$ then we have the following two equations: \begin{eqnarray*} (\delta_x+\delta_t)u=u_x+u_t=v\\ (\delta_x-4\delta_t)v=v_x-4v_t=0 \end{eqnarray*} Now for $v$ we simply find $$v=h(t+4x)$$ where $h$ is an arbitrary function of one variable. Now what remains is find $u$ such that $$u_x+u_t=h(t+4x)$$ I am stuck here, I thought about making a change of variables $\zeta=x+t$ and $\eta=x-t$ and thus using the product rule to show that $u_x=u_{\zeta}+u_{\eta}$ and $u_t=u_{\zeta}-u_{\eta}$ and thus $u_x+u_t=2u_{\zeta}$ and we need to solve $$u_{\zeta}=h(t+4x)$$ (I left out the factor 2 because $h$ is an arbitrary function). Do I simply integrate now and conclude $$u=f(\zeta)h(t+4x)+g(\eta)=f(x+t)h(t+4x)+g(x-t)$$ This seems wrong to me...  Some help would be greatly appreciated! Suppose I am given a $2$x$2$ matrix $A=$ \begin{pmatrix} a &amp; b \\ c &amp; d \end{pmatrix}  And an initial vector $x_n$ = \begin{pmatrix} x_0 \\ y_0\end{pmatrix}.  Under repeated iteration $x_{n+1} = Ax_n$, we find that $x_{n+1}$ converges to a line in the direction of the $eigenvector$  of $A$ of the form $X$= $[u,mu]$ where $m$ is the slope of the line.  I know that this process somehow also involves the largest $eigenvalue, \lambda,$ of $A$, though I am unsure how it connects.  My question is: How does the largest eigenvalue connect to this repeated iteration, how do I find the slope of the line of convergence $m$, and what is meant by the "direction of the eigenvector"? Make IN clause behave like AND clause I've asked the same question on , but got no answer, so that's why I'm asking it here (I've read that simple sql questions should be asked at SO, but I have no choice).  Suppose I have 3 tables: posts, post_categories and categories. I'm implementing some kind of page with filters where I can filter posts by categories. User can select multiple categories. When he selects more than one, they should be summed. I can't get it working. What I have now is simple IN() SQL clause:  SELECT posts.id, post_categories.category_id FROM posts  JOIN post_categories ON posts.id = post_categories.post_id  WHERE post_categories.category_id IN (1,2,3) LIMIT 10;   But it is not matching all ids, it is OR and I need AND. What I need here is to find all posts that have categories with id=1 AND id=2 AND id=3, but instead this query returns posts that have at least one category from the IN() list. Maximal order of an element in a symmetric group If we let $S_n$ denote the symmetric group on $n$ letters, then any element in $S_n$ can be written as the product of disjoint cycles, and for $k$ disjoint cycles, $\sigma_1,\sigma_2,\ldots,\sigma_k$, we have that $|\sigma_1\sigma_2\ldots\sigma_k|=\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$.  So to find the maximum order of an element in $S_n$, we need to maximize $\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$ given that $\sum_{i=1}^k{|\sigma_i|}=n$. So my question:      How can we determine $|\sigma_1|,|\sigma_2|,\ldots,|\sigma_k|$ such that $\sum_{i=1}^k{|\sigma_i|}=n$ and $\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$ is at a maximum?   Example  For $S_{10}$ we have that the maximal order of an element consists of 3 cycles of length 2,3, and 5 (or so I think) resulting in an element order of $\operatorname{lcm}(2,3,5)=30$.  I'm certain that the all of the magnitudes will have to be relatively prime to achieve the greatest lcm, but other than this, I don't know how to proceed. Any thoughts or references? Thanks so much. Get latest Flash player on Ubuntu I know, it's been asked before but I couldn't really get a satisfying answer for some details/backgrounds and I guess it's an important question for many.    Some application seem only to be running with Adobe Flash 15 (or at least I know it does, because I have that version on my Windows Partition).  The official Adobe website says:     NOTE: Adobe Flash Player 11.2 will be the last version to target Linux as a supported platform. Adobe will continue to provide security backports to Flash Player 11.2 for Linux.   Some search on the web like "Ubuntu Adobe Flash 15" or similar does not return any good websites.  I found something that says   (using a "pepper-based version"), and  .   Is it impossible to use this for Firefox too? Would it be a privacy risk?  Are there no alternative projects (I know it's closed source but there are so many so very bright people out there using something similar to wine but just for the plugin....)?  How about the Mac-Version? Shouldn't someone be able to port that one to Linux? How do I check if an element is really visible with JavaScript? In JavaScript, how would you check if an element is actually visible?  I don't just mean checking the visibility and display attributes. I mean, checking that the element is not   visibility: hidden or display: none underneath another element scrolled off the edge of the screen   For technical reasons I can't include any scripts. I can however use  as it is on the page already. using a:hover to change the color of an image I'm studying measure theory and two question came to my mind:        If $f:\mathbb{R}\to\mathbb{R}$ is monotone and $B\subseteq\mathbb{R}$ is borel, is the image $f(B)$ borel?   If $f:\mathbb{R}\to\mathbb{R}$ is a monotone function (say, non-decreasing), does there exist a sequence of continuous functions $f_n:\mathbb{R}\to\mathbb{R}$ converging pointwise to $f$?      Here's the motivation for those questions: Let $(X,M)$ and $(Y,N)$ be measure spaces.   It's known that if $\mu$ is a measure on $(X,M)$ and $f:X\to Y$ is measure, then we have the pushforward measure $f_*\mu(A)=\mu(f^{-1}(A))$ on $(Y,N)$. What if we were to define a "pullback measure"? Given a function $f:X\to Y$ such that $f(M)\subseteq N$ (i.e. $f$ maps measurable sets to measurable sets) and a measure $\nu$ on $N$, the natural formula would be $f^*\nu(A)=\nu(f(A))$. So we ask if is there a good amount of functions which map measurable sets to measurable sets in $\mathbb{R}$, and monotone functions seem like good candidates (for strictly monotone, continuous functions, the result is valid and there are several answers on the web). If this were true, maybe we could use some convergence argument to solve the problem above. Find executable files recursively I have got the directory called Test and a few directories inside it. Both Test and the directories inside it have executable files. I'd like to print them with ls. I'd use this command.  ls -l `find Test/ -perm /u=x,g=x,o=x -type f`   Is this a good/right/quick command or not?  My solution is:  find Test/ -executable -type f -exec ls -l {} \;   and got the same result as warl0ck and pradeepchhetri offered. Consider the sequence $(\phi_n)_{n\in \mathbb{N}}$ of test-functions $\phi_n\in \mathcal{D}(\mathbb{R})$ defined by  $$\phi_n(x) = \dfrac{n}{\sqrt{\pi}}e^{-n^2x^2}.$$  I want to show that this is a delta sequence, in the sense that:  $$\lim_{n\to\infty}(\phi_n,\psi)=(\delta,\psi)=\psi(0), \quad \forall \psi\in \mathcal{D}(\mathbb{R}).$$  In that case we know that we have  $$(\phi_n,\psi)=\dfrac{n}{\sqrt{\pi}}\int_{-\infty}^{\infty}e^{-n^2x^2}\psi(x)dx.$$  The problem here is to compute this integral. The function $x\mapsto e^{-n^2x^2}\psi(x)$ has no singularities, hence contour integration wouldn't help. Integration by parts or substitution also doesn't seem to be of great help.  The major problem is that there is a function $\psi$ inside the integral about which we don't know really anything apart from the fact that it is $C^\infty$ and with compact support.  How can we compute this integral and in the end show that the sequence $(\phi_n)$ is a delta sequence?  Just to make clear, I'm here doing all of this in the context of the Riemann integral. Global keyboard capture in C# application I want to capture a keyboard shortcut in my application and trigger a dialog to appear if the user presses a keyboard combo even outside of the app. Similar to Google Desktop Search's Ctrl, Ctrl to bring up the search dialog.  I have tried using some keyboard hook modules out there that basically use Win32 interop to get this effect but each implementation I've tried ties down the keyboard to some extent to where you start getting weird behaviors when the application is doing something intensive. Such as loading a large amount of data, this would cause the keyboard and mouse to lockup.  I'm looking for a lightweight solution that would allow this to be done without tying down the keyboard and mouse.