Dictionary unpacking in Python 2
How do I merge two dictionaries in a single expression (taking union of dictionaries)?
I made a skin by using Skincraft and I exported it to minecraft.net. I chose my skin and uploaded it. At the top it says,      "Your skin has been changed! Please wait a few seconds for it to   update."   I went to Minecraft, clicked singleplayer and chose a random world at the top. I looked at my character, but it's still default. Multiplayer won't load for some reason. I don't know what I've done wrong! how do I get my code to use the value of the $HOME variable? I'm trying to put together a generic script that will check the existence of several key directories for various users on different servers. Additionally, I want to leverage each user's $HOME variable.  For eg, let's say this were true:   on server 1: jdoe's home is /home/jdoe  on server 2: jdoe's home is /opt/jdoe2 server 3 hasn't been built yet; we won't know where they build his $HOME until the server is built. on server 4: mysql's home is /opt/home/mysql   This is what I have for my important directories (ordered from most to least impt):  $ cat mylist.txt $HOME/most_impt_dir1 $HOME/most_impt_dir2 $HOME/most_impt_dir3 $HOME/misc $HOME/junk   ...I want to find the most impt dir owned by this user.   Here's what I'm trying:  for i in `cat mylist.txt` do    if [[ -O $i ]] &amp;&amp; [[ -d $i ]]; then     echo "found it: $i"     break   else     echo "$i is not it."   fi  done   The above code does not work for anything in my list because it is literally checking for dirs beginning with $HOME. How do I get my code to use the value of the user's $HOME variable? Both  (if you take a list of values, the distribution of the most significant digit is rougly proportional to the logarithm of the digit) and  (given a corpus of natural language utterances, the frequency of any word is roughly inversely proportional to its rank in the frequency table) are not theorems in a mathematical sense, but they work quite good in the real life.   Does anyone have an idea why this happens?  (see also ) At level 18,  get the  feature (PHB, p. 103):     Beginning at 18th level, when you roll damage for a spell and roll the highest number possible on any of the dice, choose one of those dice, roll it again and add that roll to the damage. You can use the feature only once per turn.   When you score a critical hit with an attack (even a spell attack), you double the amount of dice you roll.  Does the additional damage die from Spell Bombardment also get rolled twice on a critical hit? Python, Unicode, and the Windows console When I try to print a Unicode string in a Windows console, I get an error . UnicodeEncodeError: 'charmap' codec can't encode character .... I assume this is because the Windows console does not accept Unicode-only characters. What's the best way around this? Is there any way I can make Python automatically print a ? instead of failing in this situation? Edit:  I'm using Python 2.5.  Note: @LasseV.Karlsen answer with the checkmark is sort of outdated (from 2008). Please use the solutions/answers/suggestions below with care!!  is more relevant as of today (6 Jan 2016). a 2d planet in the center, where the players will be able to walk on it and also will be affected by center gravity. planet will be static and there won't be any other planets. so;  Is there a way that I can change the gravity position? yes you can adjust gravity via project settings but I want it to be in the middle x,y,z(0,0,0)  I have tried creating my own gravity but it wasn't very useful because objects wouldnt fall, stand on foot and also in contact with another object they would vibrate instead of standing still. (if they stand on the planet they would vibrate)          private void FixedUpdate() {     foreach(GameObject item in grav)     {         Attact(item);     } }  private void Attact(GameObject gmf) {     Rigidbody2D rgg = gmf.GetComponent&lt;Rigidbody2D&gt;();      Vector3 direction = rg2d.position - rgg.position;     float distance = direction.sqrMagnitude;      float forceMag = (10 * rgg.mass) / distance;     Vector3 force = direction.normalized * forceMag * 10;      rgg.AddForce(force); }   I can create a script that will change the gravity by the opposite of the object's position. this does work but I cannot see any way to do it for more than one object. Density of random variables Let $X$ and $Y$ be independent random variables with respective densities: $f_X (x) = xe^{-\frac{x^2}{ 2}} 1_{]0,+\infty[} (x)$ and $ f_Y (y) =  \frac{1}{\pi \sqrt{1-y^2}} 1_{]-1,1[} (y)$  Let $U:=XY$ and $V:=X\sqrt{1-Y^2}$  I try to check whether U and V are independent and which law they follow.  What I did:  After some calculations, I found the density of $(U,V)$:  $ f_{(U,V)}(u,v)=\frac{1}{\pi } e^{-\frac{u^2}{ 2}}1_{\mathbb{R}}e^{-\frac{v^2}{ 2}}1_{\mathbb{R}_+^* }$ Which mean that $(U,V)$ follows a $ \mathcal{N}(0,1)$ law (because $u^2+v^2=x^2$) and that  U and V are independent because $f_{(U,V)}$ can be factored as the products of densities of $U$ and $V$  My question:  There is a factor $\frac{1}{\pi}$ and I don't know to which density it will belong: to $U$ density or to $V$ density?  Many thanks! Hisoka hinted that Gon is his treasure and also his prey, but it can't be both, right? Because in the end, he didn't want Gon to die no matter what.  So it's weird that he didn't want Gon to die but also made him his prey to fight till death. Is it sexual for Hisoka or what? I still remember the 'Schwing' thing. Fibonacci addition law $F_{n+m} = F_{n-1}F_m + F_n F_{m+1}$ Question: Let $F_n$ the sequence of Fibonacci numbers, given by $F_0 = 0, F_1 = 1$ and $F_n = F_{n-1} + F_{n-2}$ for $n \geq 2$. Show for $n, m \in \mathbb{N}$: $$F_{n+m} = F_{n-1}F_m + F_n F_{m+1}$$   My (very limited) attempt so far: after creating a small list of the values $F_0=0, F_1=1, F_2=1, F_3=2, F_4=3, F_5=5, F_6=8, F_7=13, F_8=21, F_9=34, F_{10}=55$ i can see that yes it does seem to work for instance $F_{6+3}=F_5 F_3 +F_6 F_4 = 10 +24 = 34 = F_9$. However, I really don't know where to begin as showing that this must hold in general terms. Should I be looking to use limits? Or perhaps induction? What is the best way to solve this? The Sharpshooter feat includes an interesting feature: you can choose to take -5 penalty to hit with a ranged weapon attack to increase its damage by 10. Normally, I'd dismiss the trade-off as too situational, but I've only just thought of combining it with the Archery fighting style (+2 to hit with ranged weapon attacks).  After building a sample character using these features, the end result looks quite effective. My questions are: Is this build valid? Have I interpreted the rules correctly? If so, how well does it compare against other damage-focused builds?  5th level variant Human Fighter:   Ability Scores (via point buy): Str 10, Dex 16, Con 16, Int 9, Wis 12, Cha 10 HP: 47, AC: 17 (or 18 with disadvantage on Stealth) Weapons: Hand Crossbow x 2 Fighting Style: Archery Martial Archetype: Battle Master (with the Precision Attack maneuver) Feat (variant Human): Crossbow Expert Feat (4th level ability score improvement): Sharpshooter   The end result is a fighter capable of hitting targets 120' away, behind 1/2 or 3/4 cover, or engaged in melee with him, all without penalty. Normally, he can make 3 such attacks per round (Attack action + Extra Attack + Crossbow Expert's bonus attack). Once per short rest he can make 5 attacks per round via Action Surge (Attack action 1 + Extra Attack, Attack action 2 + Extra Attack, Crossbow Expert's bonus attack).  His normal attack bonus is +8 (3 proficiency, 3 Dexterity, 2 Archery fighting style), and normal damage is 1d6+3. Not amazing damage, but nice accuracy and flexibility (attacks can be focused on one target, or spread around; works equally well in melee and ranged combat).  The real winner is his ability to take -5 on any of these attack rolls to increase the damage by 10, to an average of 16.5 per shot (excluding crits). If he lands his usual 3 attacks, that's ~47 damage; 5 attacks is ~83. While the -5 to hit seems imposing, he's still got superiority dice: he can increase his attack roll by 1d8 after seeing the result, up to 4 times per short rest. And even without the superiority dice, his attack bonus is still an acceptable +3; ok for hitting low AC targets, or those granting advantage on attack rolls (e.g. surprised or prone + adjacent).  With a decent AC, a Fighter's HP, and the Second Wind feature, he can also take a decent amount of damage. He'll also have decent Strength, Dexterity, and Constitution saving throws.  This build seems almost too well rounded. Unlike a blaster, he only requires short rests to recover his big hitters. Unlike a brawler, he can target just about anything on the field at a moment's notice. Have I missed any rules, or overlooked any drawbacks? Why am I getting shopping trolley notifications about local store savings? I am getting "Shopping Trolley" notifications appearing regularly. The notification looks like this:   The notification is about "Store savings" at a local supermarket and that is it!   Is this notification from Google Maps or another application like Google Assistant? I'm struggling to find the specific setting to disable the notification.  I am also interested to know if this notification could in any way be targeted advertising generated by the store. My marketing preferences with the store are opt-out and this strikes me as very dumb advertising. Surely Google isn't doing this? Is there a means that a store can generate notifications like this? Could it be targeted if they have my email address?  These are pain and I want to understand why they are spamming me and disable them without disabling everything else.  I can see various options under Google Maps, settings, notifications. Which setting would apply? Could it be "New on maps, Get occasional updates about new features in your area"? I can't see what setting to suppress!  Thanks for all help. Whence came the different varieties of the "long i" diphthong? What is the origin of “long long i” before voiced consonants (the [ai] of wide, while, &amp; tribe) versus “short long i” before unvoiced consonants (the [ʌi] of white, wife, &amp; wipe)? When did this difference appear? Is it just a secondary distinction, or are there minimal pairs for these two diphthongs?  Obviously the distinction is not present in all accents—though its presence in most leads me to believe it's not a late arrival—and yet I've never found a dictionary that distinguishes them. What is the intuitive meaning of line integral with respect to x? I know how the line integral is calculated, but I want to know what the meaning of line integral with respect to x is, I mean, intuitively. The integral is $\int_C f(x,y) dx$ or it can be $\int_C f(x,y) dy$. ($C$ is a curve here) Thanks. How to save/restore Sublime Text 2 configs/plugins to migrate to another computer? Let $x$ be transcendental over $F$. Let $y=f(x)/g(x)$ be a rational function. Prove $[F(x):F(y)]=\max(\deg f,\deg g)$ Let $F$ be a field and $x$ transcendental over $F$. Let $y=f(x)/g(x)$ be a nonconstant rational function with relatively prime polynomials $f,g\in F[x]$. Prove $[F(x):F(y)]=\max(\deg f,\deg g)$.  My attempt: By replacing $y$ with $\frac{1}{y}$ if necessary we assume $\deg g\geq\deg f$. By the Euclid algorithm we assume $\deg g&gt;\deg f$. Then $\deg g=\max(\deg f,\deg g)$, let $n=\deg g$. Let $R(t)$ be this polynomial $$R(t)=yg(t)-f(t)=\frac{f(x)}{g(x)}g(t)-f(t)$$ Then $\deg R=\deg g=n$ because $n=\deg g&gt;\deg f$. The coefficients of $R(t)$ lie in $F(y)$ and hence $R(t)\in F(y)[t]$. Clearly $R(x)=0$.  Now I only have to prove $R(t)$ is actually the minimal polynomial of $x$ over $F(y)$. I believe the next step is to obtain a contradiction that $R(t)$ being reducible can lead to $f,g$ being not coprime, but I can't figure out how to do that.  P.S. A hint is preferred over a full answer. What does the symbol $\subset\subset$ mean? In some texts (mainly complex analysis or harmonic analysis) I sometimes see the following double subset symbol $\subset\subset$ for inclusion relation of two regions, e.g., $\Omega$ and $\Omega'$ are two regions in $\mathbb{C}$ such that $\Omega \subset\subset \Omega'$. I never figured out what it means exactly; I always interpreted it as the closure $\overline{\Omega}$ is contained in $\Omega'$ (so that some nasty boundary effects can be avoided). Is that right? Or does $\subset\subset$ mean some other kind of inclusion? Thanks. How do I make log4j clear a log at startup? I propose to let users vote on closing activities of moderators and other users with closevoting power.  Like this:       closed as exact duplicate by Michael Mrozek, waiwai933, Arjan, YOU, Yi Jiang 6 hours ago      This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question.   Make it like this:     closed as exact duplicate by Michael Mrozek, waiwai933, Arjan, YOU, Yi Jiang 6 hours ago   fair/unfair close? [agree] [disagree]      This question covers exactly the same ground as earlier questions on this topic; its answers may be merged with another identical question.   Then the system will gather statistics and automatically grant more closing powers to those users who enjoy support of the community and revoke those powers from those mostly casting contradictory votes.  It would seem that granting the same powers to everybody has not resulted in balance but in public disorder. Perhaps it is reflective of American lifestyle (everybody has the right and means to shoot anybody), but it's not the best way to run a society by far.  What I'm trying to say is that while granting powers to everybody in advance is generous, the maturity to wheel these powers in a fair way must be proven. By introducing community feedback this assessment process can be automatized. Just recently, the right-click context menus in Windows 7 have been acting in a kind of left-handed way. That is, when possible, the initial menu appears to the left of the mouse pointer. When I hover over a submenu option, the next level of context menu appears to the left of the first and so-on.  Basically, what normally happens when you're right at the right-hand edge of the screen is happening all the time - except when I'm at the left-hand edge. Perhaps it's some kind of left-handed users option, but that doesn't seem likely - more like a right-to-left language option, except that I've never even tried to use a right-to-left language.  I haven't checked every app. for the issue - probably only Windows Explorer, definitely not in Firefox, for the moment that's as far as I've checked.  Scratch that - this affects menu bars as well as context menus. The menus dangle down to the left of the menu-bar item instead of the right, and submenus open to the left too. This seems to apply to most applications, but not too Firefox or Thunderbird.  I find this extremely annoying.  I have no idea how this occurred, though it isn't the only weird glitch I've had in Windows 7 in the last few days - see   I assume there's a setting somewhere that has got changed, but I can't find anything. There's also a chance that I've suffered some kind of registry corruption, so I might need to apply a fix in the registry - not something that scares me, but I need to know what to fix and how.  So - does anyone know what setting has been changed, and how I can fix it?  Also, beyond CCleaner (which I already have), are there any tips on making sure that the registry stays clean and sane?  Finally, both Microsoft Security Essentials and Malwarebytes Antimalware seem happy that I don't have a malware problem. Should my recent glitches make me doubt that? Is there a way to get the (to-be-generated) SQL from a Hibernate Criteria?  Ideally, I would have something like:  Criteria criteria = session.createCriteria(Operator.class);  ... build up the criteria ... ... and then do something like ...  String sql = criteria.toSql()  (But this of course does not exist)   The idea would then be to use the SQL as part of a huge 'MINUS' query (I need to find the differences between 2 identical schemas - identical in structure, not in data - and the MINUS is not supported by Hibernate)  (BTW I know I can check the SQL from the log files)