This question could sound something stange, but normally you can get values by the key, e.g:  &gt;&gt;&gt; mydict = {'a':1,'b':2,'c':3} &gt;&gt;&gt; mydict['a'] 1 &gt;&gt;&gt; mydict['b'] 2 &gt;&gt;&gt; mydict['c'] 3   But I need to do:  &gt;&gt;&gt; mydict[1] 'a' &gt;&gt;&gt; mydict[2] 'b' &gt;&gt;&gt; mydict[3] 'c' # In this case, my dictionary have to work like &gt;&gt;&gt; mydict = {1:'a',2:'b',3:'c'}   In my program my dictionary could be open by the two ways, I mean:  &gt;&gt;&gt; mydict = {'a':1,'b':2,'c':3} # Sometimes I need the value of a letter: &gt;&gt;&gt; mydict['a'] 1 # And somethimes, I need the letter of a value. &gt;&gt;&gt; mydict.REVERSAL[1] a   I can do something like: (I don't know if this work, I don't test it)  &gt;&gt;&gt; mydict = {'a':1,'b':2,'c':3} &gt;&gt;&gt; mydict['a'] 1 # etc... &gt;&gt;&gt; def reversal(z): ...     tmp = {} ...     for x,y in z.items(): ...         tmp[y] = x ...     return tmp &gt;&gt;&gt; mydict = reversal(mydict) &gt;&gt;&gt; mydict[1] a # etc &gt;&gt;&gt; mydict = reversal(mydict) &gt;&gt;&gt; mydict['c'] 3 # etc, etc, etc...   Is there an easy way to do that?  FIRST: I know about chr() and ord(), my code isn't about letters... this is only and example.  SECOND: In my dictionary there won't be two same values, so there won't be any problems with duplicate keys...
Given a dictionary like so:  my_map = {'a': 1, 'b': 2}   How can one invert this map to get:  inv_map = {1: 'a', 2: 'b'}
I'm using Emacs with AUCTeX to do all my LaTeX. When it comes to syntax highlighting it seems that all mathematics is by default just orange. Do you know of a mode or package that adds some more fine grained syntax highlighting? For example all commands (\foo), matching braces, sub- and superscripts, etc. should get a different color. What is the difference between "why are you worried" and "why you are worried"? Magnetic Field in the presence of a conductor I am studying for my quals and came across an old question that reads like the following:      There are two regions in space separated by an infinite conducting plane. Region 1 has a magnetic dipole of moment $\vec{\mu}$ located a distance $d$ from the plane. What is the magnetic field $\vec{B}$ everywhere in region 1?   I know that for a perfect conductor (superconductor), the normal component of $\vec{B}$ is zero–although I don't exactly know why–but I don't know if that is the case when the problem involves a "conductor" (not explicitly a perfect conductor).  TL;DR: Can anybody give me some insight about the magnetic boundary conditions of a stationary magnetic field in the presence of a conductor?  Thanks! Why is polyploidy lethal for some organisms while for others is not? is the multiplication of number of chromosomal sets from 2n to 3n (triploidy), 4n (tetraploidy) and so on. It is quite common in plants, for example many crops like wheat or Brassica forms. It seems to be rarer in animals but still it is present among some amphibian species like Xenopus.  As I know in mammals polyploidy is lethal (I don't mean tissue - limited polyploidy). I understand that triploidy is harmful due to stronger influence of maternal or paternal epigenetic traits that cause abnormal development of placenta, but why there is no tetraploid mammals? How can I make a message appears on my PC when my phone is ringing? When I'm at work, I usually have a headset on my head and I am listening to music. My phone is always on vibrate to respect co-workers.  However, I don't keep the phone in my pocket because of its size, so I don't feel it vibrating.  I miss a lot of calls.  I was wondering if it's possible to forward "phone is ringing" notifications to the PC, ideally via a Bluetooth connection.  I would not mind installing a 3rd-party app on the phone or software on the PC. How to raise a complex number to the power of another complex number? How do I calculate the outcome of taking one complex number to the power of another, ie  $\displaystyle {(a + bi)}^{(c + di)}$? Stop inserting hard line-wraps in blockquotes! When you use the markdown editor's blockquote feature (the quote button / Ctrl+Q), it inserts hard line-wraps in the markdown source automatically for you. That is, it transforms text like this:  Hindus regard it as an earthly manifestation of the goddess Tulsi, a consort of the god Vishnu.   The offering of its leaves is mandatory in ritualistic worship of Vishnu and his forms like Krishna and Vithoba.   Into text like this:  &gt; Hindus regard it as an earthly manifestation of the goddess Tulsi, a &gt; consort of the god Vishnu.  &gt;  &gt; The offering of its leaves is mandatory in ritualistic worship of &gt; Vishnu and his forms like Krishna and Vithoba.   The editor should instead transform it into this:  &gt; Hindus regard it as an earthly manifestation of the goddess Tulsi, a consort of the god Vishnu.  &gt;  &gt; The offering of its leaves is mandatory in ritualistic worship of Vishnu and his forms like Krishna and Vithoba.   That is, without adding any newlines.   Why on earth does it insert hard line-wraps!? Both these forms look the same when rendered, but the current way makes it more difficult for us to go back and edit the blockquoted text later if need be.   This is particularly objectionable functionality for sites that use MathJax - while the hard line-wraps don't impact the rendered output, the additional &gt; that are inserted do (they manifest as greater-than signs if they get inserted within MathJax $$...$$). See this post on Meta.Math.SE for more details: .    I found  that this behavior is apparently :      The "reflow the text when you click blockquote" is a deliberate feature, intended to improve the readability on quoted text.   Seriously? Are there any browsers that don't soft-linewrap textareas anymore? How is hard-wrapping at 70(?) characters better than soft-wrapping at $textareawidth? If readability is the concern here, then why not hard-wrap all non-code upon post submission? Email to salesforce error While sending an attachment as an email to be attached to the salesforce record.Salesforce is giving the below given error.  Generating server: mx1.madison.gov  6-2j26dncatawfg1112dv2uwxupq9hzfgmjrrlrn2rx48cxm93nt.8-dea8eae.c.le.salesforce.com mx1-asg.mta.salesforce.com # #SMTP#  Is this salesforce problem or it is the Internal company server problem as I could see that error mentions company server name also.But to me doesn't look like company server error. I'm reading through  for the , which contains this figure on page 16:    This is of course an instrumentation amplifier that apparently uses an inverting amplifier's output instead of a ground in the lower-right corner of the above figure, but what really perplexes me is the 100 k&Omega; resistors attached directly to the noninverting inputs of three of the four amps. I don't recall seeing an instrumentation amplifier circuit in books or application notes that have them, and all of the instrumentation amplifiers I've built using the three op-amp scheme works fine without them.  The datasheets specifies an input resistance of 1012 &Omega;, which is 10,000,000 times greater than 100 k&Omega;, so it doesn't seem to add anything to the already high-impedance JFET inputs. I thought perhaps it has something to do with input bias currents, but that's just me making a wild stab in the dark.  Curiously, figure 26 in the same datasheet (page 18) shows a two-op-amp version of an instrumentation amplifier without the 100 k&Omega; resistors at the noninverting op-amp inputs!  What's the purpose of the 100 k&Omega; resistors at the noninverting inputs in the above circuit? Am I missing something completely obvious? C's strtok() and read only string literals char *strtok(char *s1, const char *s2)      repeated calls to this function break string s1 into "tokens"--that is   the string is broken into substrings,   each terminating with a '\0', where   the '\0' replaces any characters   contained in string s2. The first call   uses the string to be tokenized as s1;   subsequent calls use NULL as the first   argument. A pointer to the beginning   of the current token is returned; NULL   is returned if there are no more   tokens.   Hi,   I have been trying to use strtok just now and found out that if I pass in a char* into s1, I get a segmentation fault. If I pass in a char[], strtok works fine.   Why is this?  I googled around and the reason seems to be something about how char* is read only and char[] is writeable. A more thorough explanation would be much appreciated. I was confused, trying to copy some files from one PC to another. I have it figured out, but the syntax is still confusing to me. This works:  scp ~/Desktop/Volenteer.png jay@server.ip:~j0h/b   which puts Volenteer.png in the folder /home/j0h/b.  However, this doesn't work:  scp ~Desktop/Volenteer.png     jay@server.ip:~j0h/b   This also fails, giving an exit status 1 file not found:  scp ~/Desktop/Volenteer.png     jay@server.ip:~/j0h/b   As does this:  scp ~Desktop/Volenteer.png     jay@server.ip:~j0h/b   So clearly, there is some difference between ~ and ~/ That difference is the presence of /   $~/ bash: /home/j0h/: Is a directory $ ~ bash: /home/j0h: Is a directory   So why in scp, does the ~ resolve to ~/ ? That is a guess, I cant verify that's what is happening.  But it seems inconsistent, and therefore confusing.  Is this a bug in scp? or is there something about tilde I am missing? I can't use the terminal while gedit command is running I recently installed 12.04. When I try to edit a file with gedit, I can't use the terminal until I close the editing file or I have to open a new terminal. But I think I didn't have this problem with 11.04, however I'm not sure. Is there anyway to avoid this and to use same terminal while editing files. Economics.SE's favicon is missing in action Cardinality and infinite sets: naturals, integers, rationals, bijections Filter dict to contain only certain keys? Can I make an ender portal on creative? I've updated Minecraft PE, and in the update notes it states that they've added the End. But when I made a new creative world and built a portal, it didn't work.  I've been looking online at tutorials, but cannot get the portal to open. So how do you create an Ender Portal? So I was searching for one of my own websites on Google: http://www.botlibre.com  and to my surprise found some clones of my website, like:  http://83waystowasteyourtime.adidas.com  and:  http:// mediaiq.astral.comm  My question are:   Why are they creating clones of my website?  Some kind of SEO scheme or what? What gain could they be getting? How do they have a URL at adidas.com and astral.comm?  I assume it's not Adidas steeling my content. How do I shutdown these sites and stop people from stealing my content? (on Tomcat) When Cantor's Intersection theorem won't work with closed sets Give an example to show that Cantor's Intersection Theorem would not be true if compact sets were replaced by closed sets.    Compact set is closed and bounded, so what I'm going to find is something that is closed but not bounded.  By the Cantor theorem, which says that a decreasing sequence of non-empty compact subset will have a non-empty intersection.  What I was trying to approach is how two sets just "touched" and as if they have not bounded, two sets "touched" nothing. But I cant give an example for that I've fitted my model and am trying to understand whether it's any good. I've calculated the recommended metrics to assess it ($R^2$/ AUC / accuracy / prediction error / etc) but do not know how to interpret them. In short, how do I tell if my model is any good based on the metric? Is an $R^2$ of 0.6 (for example) sufficient to let me proceed to draw inferences or base scientific/business decisions?     This question is intentionally broad, to cover a wide variety of situations that members frequently encounter; such questions could be closed as duplicates of this one. Edits to broaden the scope beyond the metrics mentioned here are welcome, as are additional answers - particularly those that offer insight about other classes of metrics. Can I bake in a convection microwave? I have microwave oven, but I can't bake cakes and cookies in it. So I need an electric oven, but people are suggesting I buy a convection microwave to do both baking and normal microwaving. Will that work? Or do I really need to get an electric oven to bake?