How to read arguments from bash
Creating bash scripts that take arguments
A method to count occurrences in a list How do the Planets and Sun get their initial rotation? Why do Venus and Mercury rotate so slowly compared to other planets?  Why does Venus rotate in a different direction to Mercury, Earth and Mars? How to duplicate sys.stdout to a log file? Edit: Since it appears that there's either no solution, or I'm doing something so non-standard that nobody knows - I'll revise my question to also ask: What is the best way to accomplish logging when a python app is making a lot of system calls?  My app has two modes.  In interactive mode, I want all output to go to the screen as well as to a log file, including output from any system calls.  In daemon mode, all output goes to the log.  Daemon mode works great using os.dup2().  I can't find a way to "tee" all output to a log in interactive mode, without modifying each and every system call.    In other words, I want the functionality of the command line 'tee' for any output generated by a python app, including system call output.  To clarify:   To redirect all output I do something like this, and it works great:  # open our log file so = se = open("%s.log" % self.name, 'w', 0)  # re-open stdout without buffering sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)  # redirect stdout and stderr to the log file opened above os.dup2(so.fileno(), sys.stdout.fileno()) os.dup2(se.fileno(), sys.stderr.fileno())   The nice thing about this is that it requires no special print calls from the rest of the code.  The code also runs some shell commands, so it's nice not having to deal with each of their output individually as well.  Simply, I want to do the same, except duplicating instead of redirecting.  At first thought, I thought that simply reversing the dup2's should work.  Why doesn't it?  Here's my test:   import os, sys  ### my broken solution: so = se = open("a.log", 'w', 0) sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)  os.dup2(sys.stdout.fileno(), so.fileno()) os.dup2(sys.stderr.fileno(), se.fileno()) ###  print("foo bar")  os.spawnve("P_WAIT", "/bin/ls", ["/bin/ls"], {}) os.execve("/bin/ls", ["/bin/ls"], os.environ)   The file "a.log" should be identical to what was displayed on the screen. Before, the concept of imaginary numbers, the number $i = \sqrt{-1}$ was shown to have no solution among the numbers that we had. So we declared $i$ to be a new type of number. How come we don't do the same for other "impossible" equations, such as $x = x + 1$, or $x = 1/0$?  Edit: OK, a lot of people have said that a number $x$ such that $x = x + 1$ would break the rule that $0 \neq 1$. However, let's look at the extension from whole numbers to include negative numbers (yes, I said that I wasn't going to include this) by defining $-1$ to be the number such that $-1 + 1 = 0$. Note that this breaks the "rule" that "if $x \leq y$, then $ax \leq ay$", which was true for all $a, x, y$ before the introduction of negative numbers. So I'm not convinced that "That would break some obvious truth about all numbers" is necessarily an argument against this sort of thing. Rename all the files within a folder with prefix “Unix_” i.e. suppose a folder has two files a.txt and b.pdf than they both should be renamed from a single command to Unix_a.txt and Unix_b.pdf At what point is a creature's toughness calculated? If I have  where I can sacrifice a creature and put X 1/1 token creatures onto the battlefield, where X is the sacrificed creature's toughness.  If I have a creature that is 4/4 and cast  to give it +3/+3 then sacrifice it? Do I get 4 tokens or 7?  Also what if my 4/4 creature was dealt 2 combat damage before I sacrificed it? Do I get 2 or 4 creatures?  Finally, what about counters? If my 4/4 had a +1/+1 do I get 4 or 5 tokens? Canonical copies of sets Sometimes one needs two disjoint copies of a given set $X$. This can be canonically done by taking $\{0\} × X$ and $\{1\} × X$. Sometimes we want to identify one of the copies with the original set $X$. So I wonder, is it possible to take a disjoint copy of $X$ straight ahead? And can this be done canonically? More precisely, are the following claims true? $ \def\dom{\operatorname{dom}} \def\rng{\operatorname{rng}} \def\On{\mathbf{On}} $   For every $X$ there is a one-to-one function $f$ such that $\dom(f) = X$ and $\rng(X) ∩ X = ∅$. There is an explicit formula $φ(X, f)$ such that for every $X$ there is exactly one $f$ satisfying $φ(X, f)$ and this $f$ satisfies 1. for $X$.   Since such construction of a disjoint copy is intuitively trivial, I'm interested in proofs of 1. and 2. without using regularity, choice, or infinity.   Some ideas:   We may simply put $f(x) := (x, X)$, but we need regularity to show that $(x, X) ∉ X$. We may consider $α = \sup(X ∩ \On)$ and pair members of $X$ with some ordinals above $α$, but we need AC to well-order $X$, and we need global choice to obtain 2. Let $&lt;$ be the transitive hull of $∈$. If the relation $&lt;$ is narrow, i.e. $\{y: y &lt; x\}$ is a set for every $x$, then we may choose $z ∉ ⋃\{(\leftarrow, x)_&lt;: x ∈ X\}$ and put $f(x) := (x, z)$ since $(x, z) = y ∈ X$ would imply $z &lt; y$. Note that we don't need the axiom of infinity to define $&lt;$, but I don't know how to prove its narrowness without infinity. Can I mention professors' names in the statement of purpose? For PhD applications, I have mentioned that I am interested in some research areas. Besides, I am thinking about mentioning some professors' names, so that it shows I have read their websites and I am not just sending out generic statements applicable to many schools.  But is it good to mention some professors' names in the statement of purpose, if I don't know them personally? In what cases is it good, and in what cases it isn't?  For example, is it good to only mention    those whose research directions are aligned with my research interests, or/and those whose books or notes I have heard of, or better, might have read some parts of, or/and those who are already established and famous (such as having certain titles), or/and those that are directing the PhD graduate programs, or/and those that are heads of the departments?    What will other professors who are not mentioned think? How will you do, if it were you? How to add "Refresh" option to right click menu in Lubuntu? I have many users at the place I work, expressing the notion of switching to Ubuntu.  Most of them, for whatever weird reason wanting to know if its possible to have refresh added when you right click on the desktop.   Is that possible? This is a follow up question to my previous question  Let $k$ be a field and $V \subseteq \Bbb{A}^n$ and $W \subseteq \Bbb{A}^m$ be algebraic sets. Then it should be true that $I(V \times W ) = I(V) + I(W)$ where by $I(V)$ here we mean the extension of $I(V)k[x_1,\ldots,x_{m+n}]$. Now I believe I have proven this (see the proof at the bottom of my question) but when I look at Martin's answer , it is instead claimed that we  actually have  $$I(V \times W )= \sqrt{I(V) + I(W)},$$  and for $I(V) + I(W)$ to be a radical ideal we need $k$ to be algebraically closed.           My question is: What's going on here? I believe my claim is true even without the assumption that $k$ is algebraically closed.           Here's a proof user Sanchez told me of, which I have simplified:       First it is clear that we always have $I(V) + I(W) \subseteq I(V \times W)$. For the reverse inclusion consider a polynomial $f \in I(V \times W)$. Then we can always write $$f = \sum_{i=1}^n f_ig_i$$ where $f_i \in k[x_1,\ldots,x_n]$ and $g_i \in k[x_{n+1},\ldots,x_{m+n}]$. Now take any $b' \in W$. If for all $i$ we have $g_i(b') = 0$ then since $b'$ is arbitrary, $g_i \in I(W)$ for all $i$. Then $f \in I(W) \subseteq I(V ) + I(w)$ and we are done. Otherwise suppose there exists $b \in W$  and $i$ such that $g_i(b) \neq 0$. Then wlog we may suppose that  $g_1(b) \neq 0$.   Next, $\sum f_ig_i(b) = 0 $ on all of $V$ by assumption of $f \in I(V \times W)$. So $\sum f_i g_i(b) = p$ for some $p \in I(V)$. Now write $$f_1 = \frac{ p - g_2(b) f_2 + \ldots g_n(b)f_n}{g_1(b)}.$$  Substituting this for $f_1$ in $\sum f_ig_i$, followed by taking things mod $I(V)$ we get an  expression with only $n-1$ terms $\mod{I(V)}$. Continuing this process we will finally get an expression with $0$ terms $\mod{I(V)}$ so that $f \in I(V)$. This shows $I(V \times W) \subseteq I(V) + I(W)$ which completes the proof. Do cell carries have access to FaceTime information? On the newest iPhone, do cell phone carriers have access to FaceTime call data (such as which caller initiated and ended a FaceTime call)? I am upgrading my PC, but I'm sticking to my old HDD and gfx card. I would like to avoid reinstalling Win 8. Is this possible? Or, at least, is it possible to use Windows 8's refresh pc option?  UPDATE  It worked like a charm. Windows acted as if it was the first boot and displayed the "Getting devices ready %  " progress bar. I am not sure if this proves you can do it in every scenario, but my new gear is relatively modern (some gigabyte board with two PCIe 3.0 slots and USB 3.0 support + i5), so I guess we can agree the reinstall is unnecessary in most cases. when does a functor map products into products? A bold plus symbol in math mode What is the number of automorphisms (including identity) for permutation group $S_3$ on 3 letters? What is the number of automorphisms (including identity) for permutation group $S_3$ on 3 letters?  I believe the answer for this is 6. As we can write the group elements as below   (a)(b)(C) (ab)(c) (ac)(b) (bc)(a) (abc) (bac)   Can we generalize that for any $S_n$ onto $n$ the number of automorphisms will be $n!$ Also I cannot find this anywhere in my text, can we have a permutation $S_n$ onto $m$ where $n\neq m$? (for eg: is it possible to have a permutation group say $S_5$ on say 2 elements?) How can the Next Generation's unfamiliarity with the Borg be explained after Archer's encounter? In  Starfleet learns about a culture that we (as audience) know as The Borg. According to TNG, the Federation doesn't seem to know anything about these beings when . Although Archer's crew doesn't learn the name of the Borg, it would be reasonable that the Federation would inherit the information about such a menacing enemy and it would also be reasonable to assume the crew of the Enterprise-D to be able to match their encounter with their databases' information.  Obviously, out-of-universe the explanation is that the scripts weren't written in chronological order, but how can the apparent obliviousness about the Borg be explained in-universe? What is the fastest algorithm for finding the natural logarithm of a big number? I have a series of layers of lines (shapefiles) in My Project. The CRS of some are different and to merge them they all must have same CRS.  When I use Processing/Toolbox/Qgis_algorithims/Reproject_layer the reprojection only works if it is allowed to save to temporary file somewhere (it will not change the CRS when I reproject if I try to save and replace it in My Project directory);   I must remove the original from the layer list and reproject the temp file (without changing the CRS) to get it into my project and name it appropriately.  Is there a better way to reproject a layer in Qgis? Quadratic Formula in Complex Variables Let $a$, $b$, and $c$ be complex numbers with $a\neq0$. Show that the solutions of $az^2+bz+c=0$ are $z_1,z_2=\frac{-b\pm\sqrt{b^2-4ac}}{2a}$, just as they are in the case when $a$, $b$, and $c$ are real numbers. Why won't QGIS recognize my GPS?