I am facing one issue dimension = ['category','amount']  // Just imaging I am getting an array like this frim request for _, obj in enumerate(qs1):     kwargs.update({obj[dimensions[1]]: Count(dimensions[1],                      filter=Q(dimensions[1]=obj[dimensions[1]]))})  Here I'm getting an error like this SyntaxError: expression cannot contain assignment, perhaps you meant &quot;==&quot;? in django  If I am changing my code like this it will work , but my issue is that I am using filtering option there so I need to get the exact field name that user passed in the dimensions dimension = ['category','amount']  // Just imaging I am getting an array like this frim request for _, obj in enumerate(qs1):     kwargs.update({obj[dimensions[1]]: Count(dimensions[1],                      filter=Q(filter_data =obj[dimensions[1]]))})
Does python have the ability to create dynamic keywords?  For example:  qset.filter(min_price__usd__range=(min_price, max_price))   I want to be able to change the usd part based on a selected currency.
How can I convert a string of bytes into an int in python?   Say like this: 'y\xcc\xa6\xbb'  I came up with a clever/stupid way of doing it:  sum(ord(c) &lt;&lt; (i * 8) for i, c in enumerate('y\xcc\xa6\xbb'[::-1]))   I know there has to be something builtin or in the standard library that does this more simply...  This is different from  for which you can use int(xxx, 16), but instead I want to convert a string of actual byte values.  UPDATE:  I kind of like James' answer a little better because it doesn't require importing another module, but Greg's method is faster:  &gt;&gt;&gt; from timeit import Timer &gt;&gt;&gt; Timer('struct.unpack("&lt;L", "y\xcc\xa6\xbb")[0]', 'import struct').timeit() 0.36242198944091797 &gt;&gt;&gt; Timer("int('y\xcc\xa6\xbb'.encode('hex'), 16)").timeit() 1.1432669162750244   My hacky method:  &gt;&gt;&gt; Timer("sum(ord(c) &lt;&lt; (i * 8) for i, c in enumerate('y\xcc\xa6\xbb'[::-1]))").timeit() 2.8819329738616943   FURTHER UPDATE:  Someone asked in comments what's the problem with importing another module. Well, importing a module isn't necessarily cheap, take a look:  &gt;&gt;&gt; Timer("""import struct\nstruct.unpack("&gt;L", "y\xcc\xa6\xbb")[0]""").timeit() 0.98822188377380371   Including the cost of importing the module negates almost all of the advantage that this method has. I believe that this will only include the expense of importing it once for the entire benchmark run; look what happens when I force it to reload every time:  &gt;&gt;&gt; Timer("""reload(struct)\nstruct.unpack("&gt;L", "y\xcc\xa6\xbb")[0]""", 'import struct').timeit() 68.474128007888794   Needless to say, if you're doing a lot of executions of this method per one import than this becomes proportionally less of an issue. It's also probably i/o cost rather than cpu so it may depend on the capacity and load characteristics of the particular machine. Cancelled UK visa on entry Simplify the expression $\binom{n}{0}+\binom{n+1}{1}+\binom{n+2}{2}+\cdots +\binom{n+k}{k}$ Possible Duplicate:          I have tried changing my proxy settings in a terminal as:  export HTTP_PROXY=http://10.1.3.1:8080   and  export http_proxy=http://10.1.3.1:8080   but when I try to install a new package or update apt-get, apt-get starts displaying messages from which it seems it is trying to connect to a previously set proxy:  sudo apt-get update   0% [Connecting to 10.1.2.2 (10.1.2.2)] [Connecting to 10.1.2.2 (10.1.2.2)   I have tried setting the proxy via bashrc file but that din work either. As far as I remember 10.1.2.2 was set using GNOME GUI but I don't have access to the GUI right now so I am trying to set it from terminal. Operator Theoretic Perspectives on Bayesian Inference Let $M_n(\mathbb{F})$ be the set of all $n\times n$ with entries in $\mathbb{F}$ and let $\exp:M_n(\mathbb{C})\to M_n(\mathbb{C})$ be defined by  $$ \exp(A)=\sum_{k=0}^{\infty}\frac{A^k}{k!},$$ for all $A\in M_n(\mathbb{C}).$  I want to prove that $\exp$ is a surjective map from $M_n(\mathbb{C})$ to $GL(n,\mathbb{C})=\left\{A\in M_n(\mathbb{C})\,\middle| \det(A)\neq0\right\}$, how do I go about that?   I mean saying that $\exp:M_n(\mathbb{R})\to GL(n,\mathbb{R})$ is an analogous to saying $\exp:\mathbb{R}\to \mathbb{R}_{&gt;0}$ and this is also pretty intuitive, since, in analogy with the case of numbers, $A^0=I\;\forall A$, so $\exp(0)=I+0+\frac{0^2}{2!}+\dots=I$, so even for $A=0$ we get $\det\left(\exp(A)\right)\neq0$ and so because of the first term we can never get a zero determinant. But I have no idea how to prove the subjectiveness.  Thanks in advance. How to remove local (untracked) files from the current Git working tree Is there any way to get the ID of the element that fires an event?  I'm thinking something like:    $(document).ready(function() {   $("a").click(function() {     var test = caller.id;     alert(test.val());   }); }); &lt;script type="text/javascript" src="starterkit/jquery.js"&gt;&lt;/script&gt;  &lt;form class="item" id="aaa"&gt;   &lt;input class="title"&gt;&lt;/input&gt; &lt;/form&gt; &lt;form class="item" id="bbb"&gt;   &lt;input class="title"&gt;&lt;/input&gt; &lt;/form&gt;     Except of course that the var test should contain the id "aaa", if the event is fired from the first form, and "bbb", if the event is fired from the second form. Phase shift of 180 degrees of transversal wave on reflection from denser medium Can anyone please provide an intuitive explanation of why phase shift of 180 degrees occurs in the Electric Field of a EM wave, when reflected from an optically denser medium?  I tried searching for it but everywhere the result is just used.The reason behind it is never specified. I have a PostGIS database and have successfully consumed a table into GeoServer and published a WFS.  Are there REST endpoints available for these WFS' akin to ESRI's feature services?  How are parameters to be constructed? Time travel short story where dinosaur doesn't taste like chicken I ran across this  and it reminded me of an old short story I read a long time ago.  I read it in a collection of short stories.  It would have been a book because I borrowed it from a school library.   Probably in the 1970s or 1980s.  The book and the story would have been older, though.  Probably from the 1960s or earlier.  In the story, a scientist has a machine that he can use to view the past.  It isn't like a TV or something, though.  It opens a portal into the past that he can look through.  It is very difficult to control, though.  Pointing it at a place and time is likened to working in a hurricane.  The portal jumps and moves about randomly.  The steadier he can hold it, the clearer the past appears.  When it is really steady, he can hear sounds from the past.  It never gets really steady enough to reach through.  They try pushing tools through the portal to pick up things in the past.  The steadier the portal, the easier it is to push tools through.  It never gets steady enough for them to push a tool all the way through, though.  It just gets easier to make progress.  One day, they have the portal open and it is acting really wild.  At some point the workers take a break.  The portal is still open, and while they are loafing the portal settles down by itself and becomes steadier than it has ever been.  So steady that a piece of the past falls through.  The portal scooped a chunk of the ground out of the past.  The chunk of ground contains a nest with dinosaur eggs.  The scientist  rescues the eggs, and they manage to keep them warm enough until they hatch.  The dinosaurs are some kind of harmless things, and become the lab mascots.  Always wandering the grounds, and in and out of the lab.  One day, the have the portal open again and one of the dinosaurs wanders into the lab and walks into some high voltage terminal.  Crash, bang.  Short circuit.  All the equipment to open the portal is destroyed, and the dinosaur is roasted from the flash.  The roasted dinosaur smells good, like chicken, and the scientist's son (who has been telling the story) takes a bite to see what it tastes like.  He says "It resembled chicken the way an asteroid resembles Jupiter."   It tastes fantastic. With all of their work ruined, and the ruins of a fortune in expensive equipment scattered around them, the scientists and the labworkers all chow down on dinosaur.  Half raw, half burned to a crisp from the explosion.  They eat the dinosaur down to the bones.  They start breeding the dinosaurs, and sell them as food.  The guy's father makes a fortune selling dinosaur meat, but remains unhappy.  With money from selling dinosaur meat, he rebuilt his lab but never ever got the portal steady enough to actually visit the past or take samples.  Does anyone know the name of the story and the author, and maybe what collection it might have been in? Does the rank-nullity theorem hold for infinite dimensional $V$? The rank nullity theorem states that for vector spaces $V$ and $W$ with $V$ finite dimensional, and $T: V \to W$ a linear map,  $$\dim V = \dim \ker T + \dim \operatorname{im} T.$$  Does this hold for infinite dimensional $V$?  According to , the statement is false.  But according to , page 4, the statement is still true.  I'm thoroughly confused. launch app, capture stdout and stderr in c++ $c$ is a complex number that satisyfing $(c+\frac{1}{c}+1)(c+\frac{1}{c}) = 1$ Let $c$ is complex-number satisfying :  $(c+\frac{1}{c}+1)(c+\frac{1}{c}) = 1$  So, how could i get $(3c^{100}+\frac{2}{c^{100}}+1)(c^{100}+\frac{2}{c^{100}}+3)$ ? Let's suppose I'm a wizard casting a ranged spell. An enemy is behind cover but I suspect he'll come out, so I ready an action to cast at him when he comes out; but I don't want to risk getting charged at by another enemy and losing concentration or taking disadvantage. Can I say:  "I ready a spell. When that guy over there leaves cover, or when any enemy gets within 5 feet of me, I will cast it on that enemy"? Where's the energy in a boosted capacitor? Suppose I look at a parallel plate capacitor in its rest frame and calculate the electrostatic energy, $E$.  Next, I look at the same capacitor in a primed frame boosted in the direction perpendicular to the plane of the plates. In this frame, the $E$-field is the same strength, there is no magnetic field, and the volume over which the $E$-field extends is less by a factor $1/\gamma$. This suggests $E' = \frac{1}{\gamma} E$, but relativity states that energy transforms as $E' = \gamma E$.   Where is the missing energy? I've been try to download Xcode for work, but for some reason the Mac App Store is giving me a bit of trouble. Activity monitor shows some network usage, but in Launchpad it seems the download isn't moving.   When I go to the purchases panel of the Mac App Store, I see this.     No status, no pause button, in fact - the button has no text on it! I've tried restarting the App Store, restarting my computer, even removing the com.apple.appstore folder in /var/folders but alas, no luck.  Can anyone diagnose the issue? When I removed com.apple.appstore, Xcode still showed up on Launchpad, and clicking on it did nothing - it was frozen in time. So can I kill off this partial download and start new? We often get questions on bicycles.stackexchange about identifying a bicycles manufacturer, model, make, and year.  Often these questions are downvoted or closed -- usually with a comment attached to them that it's not necessary to know the exact model/make/year of a bicycle if you want to fix, repair, or ride your bike. Why should owners not care about the model/make/year of their bicycle? Especially when it comes to less expensive bikes (aka BSOs) and BMX bicycles? This is intended as a canonical question that we can point closed questions to. Also see      (generally not helpful for identifying a brand/model) tmux: enable mouse only when shift pressed Get name of caller function in PHP? Is there a PHP function to find out the name of the caller function in a given function?