Hi I want to remove duplicate entries in single column in my datasheet. Is there a short way to do that when writing my output file? It is python3 script.  with open(input) as infile, open (output, 'w') as outfile:     reader = csv.reader(infile, delimiter='\t')     writer = csv.writer(outfile, delimiter='\t')     for gg, poss, codee, ref, alt, *rest in reader:         gg = int(gg)         poss = int(poss)         writer.writerow([gg, poss, codee, d[group][poss-1], ref + ',' +alt] + rest)   In the last line, I want the column "ref + ',' + alt" to not have any duplicate values. With the above command, I have outputs like:  A,B,B,C G,G,A,T G,A,A T,T   I want this to be:  A,B,C G,A,T G,A T   Is there a short command that I can incorporate on the last line? or should I start a new set of command to do this? Please help me! Thank you.  EDIT with OrderedDict  from collections import OrderedDict with open(notmatch) as infile, open (two, 'w') as outfile:     reader = csv.reader(infile, delimiter='\t')     writer = csv.writer(outfile, delimiter='\t')     for gg, poss, codee, ref, alt, *rest in reader:         gg = int (gg)         poss = int(poss)         cls = ref + alt         clss = list(OrderedDict.fromkeys(cls))         writer.writerow([gg, poss, codee, d[gg][poss-1], clss] + rest)   So I used OrderedDict and it seems to give me output like the following for column "clss":  ['A','B','C'] ['G','A','T'] ['G','A'] ['T']   The 5th column which is concat of "ref" and "alt" is the only column where I want to apply this deduplication so I wrote my script in such manner. Everything looks good but there are brackets "[" "] and apostrophe "'" in each cell. How should i modify my code so they are not there?
Is there a built-in that removes duplicates from list in Python, whilst preserving order? I know that I can use a set to remove duplicates, but that destroys the original order. I also know that I can roll my own like this:  def uniq(input):   output = []   for x in input:     if x not in output:       output.append(x)   return output   (Thanks to  for that .)  But I'd like to avail myself of a built-in or a more Pythonic idiom if possible.  Related question:
Syntax of Using Math Mode: Empty Lines (Beginner Question) I'm just starting to learn LaTeX. I tried typing \begin{equation*}  (math goes here)  \end{equation*}  and I got a whole bunch of errors. It seems LaTeX interpreted the empty line as the equation: when it saw nothing there, I guess it just ended math mode? It then said my other commands needed $'s so I assume that's what happened. When I typed \begin{equation*} (math goes here) \end{equation*}  everything was fine. So I'm confused. If LaTeX sees an empty line in an environment, does it just interpret this as me changing my mind, and deciding not to use the declared environment? I am trying to monitor multiple JVMs running on different servers through an ssh tunnel.  Thanks to one of the UNIX gurus here, I have managed to get this running for a single server by:   Run jstatd on the target server Set up Visual VM to use 9696 as its socks proxy port. On my local PC, run:  ssh -L 2222:server1:22 bastion-host  On my local PC, run:  ssh -o port=2222 -D 9696 -L 1099:localhost:1099 localhost    This does the trick. Now when I try and tunnel to a second server I try:   On my local PC, run:  ssh -L 3333:server2:22 bastion-host  On my local PC, run:  ssh -o port=3333 -D 9696 -L 2099:localhost:1099 localhost    However, the last step complains with:  bind: Address already in use channel_setup_fwd_listener: cannot listen to port: 9696   Has anyone managed to do something similar?  Update:  The reason this is so complex is that jstatd is an RMI server application:    As with RMI applications, these register with an rmiregistry. Using rmi through a firewall requires me to use SOCKS as described here:    Unfortunately, visualvm only lets me set the SOCKS proxy port once, and the -D option won't allow me to forward the same local port to both servers... Why does shrinkage work? Solve for $A,B$: $\mathrm{LCM}(A,B)=168$, $\mathrm{HCF(A,B)}=12$ I expect to be working on a web application within the next several months and I'd like to "shoehorn" a Spanish language version of the site. If a large enough number of Spanish language users begin using the site we'll likely hire a professional translator (or at least recruit someone who actually knows the language), but in the meantime is there a good cheat sheet I can use for common UX keywords, like "OK", "Submit", "Cancel", "Delete" and "Save"?  I know I could use an online translator, but I'm concerned the translator would not pick up on context (thus giving me a Spanish word meaning something closer to "Take" for "Accept" or "Surrender" for "Submit", etc.)  I'm not looking for a 100% solution, just something to give me the bulk of the keywords until there's enough reason to hire a real translator. This site will be in a beta development phase for a long time, I think, so we're not expecting a huge user base to start things off. Having line color vary with data index for line graph in matplotlib? Suppose that a deck of 52 cards containing four aces is shuffled thoroughly and the cards are then distributed among four players so that each player receives 13 cards. Determine the probability that each player will receive one ace.   The answer to this is given as$$\frac{13^4}{\binom {52}4}$$  My doubt is the following:   The book justifies ${\binom {52}{4}}$ as number of possible different combinations of the four positions in the deck occupied by 4 aces. That sounds like a case of arrangements to me, so shouldn't we think about permutations and not combinations if we are concerned about how the aces are to be arranged in the deck ?. Shouldn't the denominator be ${\binom {52}{13}}$ since you are choosing 13 cards for 4 people. Windows 10 Anniversary Upgrade error 0xc1900101 - 0x30018 referring to SYSPREP How to select an element whose id is dynamic and keeps changing There is a type and search drodown which will appear after user type in the value. I need to click on the dropdown which contains the name of the drop down field.   The problem here is that there is no unique attribute present (No unique class, no unique name) &amp; the id keeps on changing after every login so cannot take id also. Where can I travel for prolonged periods of time while legally working remotely for a company in my home country? I found several questions about inbound travelers to the US in this scenario, but little about other countries: I work for a company in my home country (USA) who are open to me working remotely while traveling.   Which countries allow me to legally work remotely for a company in my home country (USA) while traveling in their country? The work has absolutely no connection to the destination country, it would take place identically entirely within the USA if I weren't traveling. Summarize the mathematical problem at the heart of breaking a Curve25519 public key It's pretty easy to generate a Curve25519 private key: generate 32 random bytes of data and then do:  e[0] &amp;= 248 e[31] &amp;= 127 e[31] |= 64   You can then generate a public key by doing  on the private key. For example, here's a random keypair I just generated:  public: e40ed268dff20db8497d0691421d00b086aad1efedcd5bd223d9eb6c0b85665f secret: e3c0e8b20ba7894882ddb37522dbe90867befcf9f31a5ce29c0d7997e0bd856d   The whole safety of public key encryption is that it is hard to take a public key and reverse the operation. Elliptic curve cryptography, as I understand it, relies on the fact that a  is hard to find. In particular, for a given large b and g, it is hard to find an integer k such that  $b^k = g$  How does that equation relate to Curve25519? Specifically, if I had a public key like the one above, how would I express, in math terms, the problem I need to solve to find the private key? How does it relate to the equation I see from time to time - $y^2 = x^3+486662x^2+x$, and the number $2^{255} - 19$?  I am guessing it is not as simple as "the private key is k and the public key is b and/or g" in the equation above. I'm also a little confused because the keys would appear to have roughly the same number of digits, which would seem to imply that there aren't many feasible values for k? How do i prove invertibility of this linear transformation Can toddlers be taught to safely navigate stairs? Is it true that for each set $M$ a given injective function $f: M \rightarrow M$ is surjective, too?  Can someone explain why it is true or not and give an example? Using Windows DLL from Linux Fontspec causes long underscores My collaborator added \usepackage[no-math]{fontspec} to a document we're working on. The result is that \_ underscores become v. long: cf. pictures below.   \documentclass{article} \usepackage[no-math]{fontspec} \pagestyle{empty}  \begin{document} \textrm{metric\_space} \end{document}   With fontspec:    Without fontspec:   The underscores are about twice as long with fontspec, and also much thinner. My question is, how do I get back to the original width? (Ideally I would like to preserve the thinness -- it looks much nicer than the original.)  In case someone asks, "why are you using \_?", the short answer is that I need to typeset identifiers involving an underscore. See  for an example in context. I'd be happy with using something other than \textrm, if it looks decent in the context of that example. If $a$ and $b$ are two roots of $x^4 + x^3 - 1 = 0$ prove that $ab$ is a root of $x^6 + x^4 + x^3 - x^2 - 1$. Why does \cal{M}_n give “M>”? Is there anyway to modify stat information like mtime or ctime manually in Python or any language at all? My PC has a build-in VT1828S chip. The connection between PC and monitor (which has built-in speakers) is through an HDMI cable.  Audio preferences shows 2 devices for audio output: analog stereo and RS880 Audio Device [Radeon HD 4200] digital stereo (HDMI).  When I plug a headphone in the rear jack and I choose the former device, everything works. When I choose the latter device, instead, no sound is heard, and video playback is too fast. It is as if video frames want to synchronise with the audio timing, but the audio timing information is wrong.  HDMI audio worked perfectly with Ubuntu 11.04, but stopped after 11.10 upgrade.