I know there're some other articles talk about how to simulate ternary operator in Python, but my question here is not how can I simulate it, but why do these ways work.  As we all know simulating a ternary operator (condition: if_true ? if_false) is done by  a if condition else b   However, there're at least two other ways to accomplish that, e.g.  (if_false, if_true)[test]   and  (expression) and (if_true) or (if_false)   Example would be  (4, 5)[4 &gt; 5]   gives 4  4 &gt; 5 and 4 or 5   gives 5
If Python does not have a ternary conditional operator, is it possible to simulate one using other language constructs?
Pokemon Egg Disappearing So my Pokemon eggs are reaching "maturity" then they just disappear. I don't get a new Pokemon. The egg just disappears. I had this happen with a 2k and a 5k now. Is this happening to anyone else? Is there any connection between a matrix being invertible and being diagonalizable? Let $A$ be an $n\times n$ matrix.  If $A$ is invertible then one of it's eigenvalues is 0.  If $A$ is diagonalizable then it has $n$ linearly independent eigenvectors.   Are these two statements true? Is there any connection between them? May I infer one from the other? Why should edits be at least six non-space characters? Earlier today I got this message:  Oops! Your edit couldn't be submitted because:   Edits must be at least 6 non-space characters; is there something else to improve in this post?   However, the purpose of my edit was to change the formatting for a message to show code.  There may have been other grammatical mistakes that could have been, but in general it is possible that there would not be.  What's the correct protocol to handle a situation like this? Integral of $\sin x \cos x$ using two methods differs by a constant? $$ \int \sin \theta\cos \theta~d \theta= \int \frac {1} 2  \sin 2\theta~ d \theta=-\frac {1} 4  \cos 2\theta$$ But, if I let  $$ u=\sin \theta , \text{ then }du=\cos \theta~d\theta $$ Then $$ \int \sin \theta\cos \theta~d \theta= \int u ~ du =\frac { u^2 } 2 =\frac {1} 2 \sin^2 \theta $$ Since $$ \sin^2 \theta =\frac {1} 2 - \frac {1} 2 \cos 2\theta$$ The above can be written as $$ \int \sin \theta\cos \theta~d \theta= \frac {1} 2 \sin^2 \theta =\frac {1} 2 \left( \frac {1} 2 - \frac {1} 2 \cos 2\theta \right)=\frac {1} 4-\frac {1} 4 \cos 2\theta   $$ Why are the two results differ by the constant $1/4$? Thank you. Leftmargin problem at the bibliography I have some trouble with the bibliography alignment. It's similar to , but that solution doesn't work for me.   Here is MWE:  \documentclass{article}  \let\oldthebibliography=\thebibliography \let\endoldthebibliography=\endthebibliography \renewenvironment{thebibliography}[1]{%   \begin{oldthebibliography}{#1}%   \setlength{\parskip}{0ex}%   \setlength{\itemsep}{0ex}%   \setlength{\itemindent}{3ex}   \setlength{\leftmargin}{0pt}% }% { \end{oldthebibliography}% }  \begin{document}  Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.    Some text. Some text. Some text. Some text. Some text. Some text. Some text. Some text.   \begin{thebibliography}{0} \bibitem{1} Baider A. Noncompact Riemannian manifolds with discrete spectra // J.Diff.Geom. -- 1979 -- V. 14 -- p. 41--57. \bibitem{2} Berger M., Gauduchon P., Mazet E. Le spectre d'une vari\'et\'e Rieman\-nienne -- Berlin-New York: Springer-Verlag, 1971. -- 251p. -- (Lecture Notes in Math.; V.~194) \end{thebibliography} \end{document}   So I need the reference labels to be aligned with the parindent, and the rest part of the each bibliography entry should have general text width. I thought it's enough to set \leftmargin=0pt, but it didn't work. I have the following result:   And what is actually more weird - it seems any value of \leftmargin doesn't have any effect to the bibliography display. The solution from the link above works fine if we don't have biblabel, but it's not my case.  Could you help me to move lines with the red marks to the green one? Plural or singular verb for collective term I have a lot of filesystems:   / on a PCI-E SSD swap on a SATA SSD /media/ned is a RAID5 array /tmp lives on RAM Parts of /home/oli are symlinked and bind-mounted in from ned I also have /media/jeff/ which is RAID1 that I store backups and bind-mount ~/.wine in off.   It's actually a lot more complicated than that. There are all sorts of extra symlinks that I need to untangle in the long run but for now I just need a nice way of taking a path and finding out where it physically lives. How would I write the equivalent of C#'s  in JavaScript?  var haystack = 'hello world'; var needle = 'he';  haystack.startsWith(needle) == true   Note: This is an old question, and as pointed out in the comments ECMAScript 2015 (ES6) introduced the  method. However, at the time of writing this update (2015) . Can we have a list of all the Stack Exchange domains somewhere, for firewall purposes? I work behind an really annoying firewall, and I just want the net admin to add all the SE websites to the whitelist. Right now I've lost access to Stack Overflow's authentication, but not Meta's... so I have to come here before I log in there.  It's driving me nuts. Basically I just want to add an exclusion rule for all SE domains; not only the website domains, but also the content domains such as gravatar.com, quantserve.com, the domain that holds static content, etc... C# List Sort by x then y Similar to , we want to sort by one element, then another.  we want to achieve the functional equivalent of   SELECT * from Table ORDER BY x, y     We have a class that contains a number of sorting functions, and we have no issues sorting by one element. For example:    public class MyClass {     public int x;     public int y; }    List&lt;MyClass&gt; MyList;  public void SortList() {     MyList.Sort( MySortingFunction ); }   And we have the following in the list:    Unsorted     Sorted(x)     Desired ---------    ---------    --------- ID   x  y    ID   x  y    ID   x  y [0]  0  1    [2]  0  2    [0]  0  1 [1]  1  1    [0]  0  1    [2]  0  2 [2]  0  2    [1]  1  1    [1]  1  1 [3]  1  2    [3]  1  2    [3]  1  2   Stable sort would be preferable, but not required. Solution that works for .Net 2.0 is welcome. Unix Truncate Column in csv file Computing sums of divisors in $O(\sqrt n)$ time? I have a sequence: $1,3,5,8,10,14,16,20,23,27,\dots$  I know that the recursive relation is:  $$p[i] := p[i-1] + \text{number of factors of $i$}, \quad \text{with $p[1]=1$.}$$  How do I solve this recursive relation in $O(n^{0.5})$ time? I have to write a program for it, and $n$ can be as large as $10^9$. So, some appropriate precomputation and prestorage is allowed, provided that they comply (memory and time wise) with the range of $n$. Proof of $(A - B) - C = A - (B \cup C)$ I have several of these types of problems, and it would be great if I can get some help on one so I have a guide on how I can solve these.  I tried asking another problem, but it turned out to be a special case problem, so hopefully this one works out normally.   The question is:  Prove $(A - B) - C = A - (B \cup C)$  I know I must prove both sides are not equivalent to each other to complete this proof. Here's my shot: We start with left side.   if $x \in C$, then $x \notin A$ and $x \in B$. So $x \in (B \cup C)$ So $A - (B \cup C)$   Is this the right idea? Should I then reverse the proof to prove it the other way around, or is that unnecessary? Should it be more formal?  Thanks! Excel VBA code to turn a row with a variable number of columns into fixed-length rows I would like to change this:  Filer   ShareName       IPAddress1    IPpaddres2    IPAddress2    ... ... .... ServerA /share1/tools   192.168.1.52  192.168.1.65  192.168.1.158 ServerA /share/library  192.168.1.65  192.168.1.61  192.168.1.155 ServerB /share/tools    192.168.1.158 192.168.1.159 ServerD /share/misc     192.168.1.7 .. ... ..... .......   To this, in a new worksheet:  Filer   ShareName       IPAddress ServerA /share1/tools   192.168.1.52 ServerA /share1/tools   192.168.1.65 ServerA /share1/tools   192.168.1.158 ServerA /share/library  192.168.1.65  ServerA /share/library  192.168.1.61  ServerA /share/library  192.168.1.155 ServerB ... ... ServerD ... ... .. ... ..... ....... Now that all SE sites have their own meta site, why doesn't Stack Apps have a meta?  Sure, Stack Apps is somewhat of a limited site (or rather, a site about a limited subject), so by some counts, it might not need a meta. However, I think there are some things that could be discussed about how Stack Apps should be run and there is no good place to do that now. Thus, I support the creation of a Stack Apps meta. Accumulation Points for $S = \{(-1)^n + \frac1n \mid n \in \mathbb{N}\}$ I was recently asked to find the accumulation points of the set $$S = \{(-1)^n + \frac{1}{n} \mid n \in \mathbb{N}\}$$  I answered that the accumulation points are $\{-1,1\}$, because despite the fact that $\frac{1}{n}$ diverges, we can still use $\frac{1}{n}$ to find an element arbitrarily close to either $1$ or $-1$, i.e. to show that there is an element in an arbitrarily small neighborhood of $1$ or $-1$. (No proof was required for this question --- this is my intuition.)  Am I right at all? Is there a proof that the ratio of a circle's diameter and the circumference is the same for all circles, that doesn't involve some kind of limiting process, e.g. a direct geometrical proof? How to add/subtract months from given date in Excel What does the tilde (~) mean at the end of a filename? What is the file with the ~ at the end of the filename for?  $ ls # aliased to add flags -rwxrwxr-x  1 durrantm  2741 May 16 09:28 strip_out_rspec_prep_cmds.sh~* drwxrwxr-x 13 durrantm  4096 May 16 14:21 ../ -rwxrwxr-x  1 durrantm  2221 May 16 14:58 strip_out_rspec_prep_cmds.sh*   This is not the same as .swp files which are there while editing.  The two files have quite a few differences and the newer file (no ~ at the end) has the most recent changes and those changes are not in the older (~) file.  Looks like I can delete it? Is the Nintendo Switch region locked? Many Nintendo devices often come with , which means if you purchase a device in one country, you won't be able to play games from another (generally).  Is the Nintendo Switch also region locked like many of its predecessors such as the Wii U and Wii?