How Generator expressions work internally in python? I have tried this following code:  result = (x for x in range(3))   for y in result:     print(y)   I am getting the following Output:   0 1 2   But when I am using this code :  result = (print(x) for x in range(3))   for y in result:     print(y)   I am getting the following output:  0 None 1 None 2 None      Can anyone explain, Why this **None** is coming in output in second code?
What does the "yield" keyword do? What is the use of the yield keyword in Python? What does it do? For example, I'm trying to understand this code1: def _get_child_candidates(self, distance, min_dist, max_dist):     if self._leftchild and distance - max_dist &lt; self._median:         yield self._leftchild     if self._rightchild and distance + max_dist &gt;= self._median:         yield self._rightchild    And this is the caller: result, candidates = [], [self] while candidates:     node = candidates.pop()     distance = node._get_dist(obj)     if distance &lt;= max_dist and distance &gt;= min_dist:         result.extend(node._values)     candidates.extend(node._get_child_candidates(distance, min_dist, max_dist)) return result  What happens when the method _get_child_candidates is called? Is a list returned? A single element? Is it called again? When will subsequent calls stop?   1. This piece of code was written by Jochen Schulz (jrschulz), who made a great Python library for metric spaces. This is the link to the complete source: [Module mspace][1].
I was wondering how to add plugins to my Minecraft server. I am using Bukkit, and the things I would like to be able to do is spawn stuff, teleport to other players, set home locations, have an in-game currency/shop and be able to teleport to homes. When to use static classes in C# Here's what :   static class CompanyInfo {     public static string GetCompanyName() { return "CompanyName"; }     public static string GetCompanyAddress() { return "CompanyAddress"; }     //... }       Use a static class as a unit of   organization for methods not   associated with particular objects.   Also, a static class can make your   implementation simpler and faster   because you do not have to create an   object in order to call its methods.   It is useful to organize the methods   inside the class in a meaningful way,   such as the methods of the Math class   in the System namespace.   To me, that example doesn't seem to cover very many possible usage scenarios for static classes. In the past I've used static classes for stateless suites of related functions, but that's about it. So, under what circumstances should (and shouldn't) a class be declared static? Is given metric space $(M, d)$. Let $A\cap B = \emptyset; \,\,\text{dist}(A,B):=\inf\{d(x,y):x\in A, y\in B\}$. $A, B$ are both closed sets. Is it possible that $\text{dist}(A,B)=0$?  The first thought comes into mind is that obviously $\text{dist}(A,B)&gt;0$, but possibly there are some tricky $d$ and $A, B$ so that it's untrue.  Thanks in advance! Elementary derivation of certian identites related to the Riemannian Zeta function and the Euler-Mascheroni Constant Is the proof of these identities possible, only using elementary differential and integral calculus? If it is, can anyone direct me to the proofs? ( or give a hint for the solution )  1)$$\int_0^\infty { e^{-x^2} \ln x }\,dx = -\tfrac14(\gamma+2 \ln 2) \sqrt{\pi} $$  2)$$\int_0^\infty { e^{-x} \ln^2 x }\,dx = \gamma^2 + \frac{\pi^2}{6} $$  3) $$\gamma = \int_0^1 \frac{1}{1+x} \sum_{n=1}^\infty x^{2^n-1} \, dx$$  and lastly,  4) $$\zeta(s) = \frac{e^{(\log(2\pi)-1-\gamma/2)s}}{2(s-1)\Gamma(1+s/2)} \prod_\rho \left(1 - \frac{s}{\rho} \right) e^{s/\rho}\!$$  I personally think the last is obtained from a simple use of the Weierstrass factorization theorem. I'm unsure as to what substitution is used.  $\gamma$ is the Euler-Mascheroni constant and $\zeta(s)$ is the Riemannian Zeta function.  Thanks in advance. Inequality involving rearrangement: $ \sum_{i=1}^n |x_i - y_{\sigma(i)}| \ge \sum_{i=1}^n |x_i - y_i|. $ Error while updating debug log trace flag I am trying to update the debug log trace flag for my user but getting the following error     Having an active trace flag triggers debug logging. You have 259 MB of the maximum 250 MB of debug logs. Before you can edit trace flags, delete some debug logs.   I have removed all existing debug logs but it is still throwing the error. On this link (Sentinel1  for a SLC product), the resolution is written as a range from the highest corresponding to low incidence angle, to the lowest resolution corresponding to high incidence angle.  My question is how is the resolution related in general to the incidence angle? And if they are really related, why is the resolution affected by the change in the incidence angle? Returning multiple values from a C++ function Is there a word to describe a person who likes chaos? I am wondering if there is a word to describe a person who likes chaos. By this I mean a few specific things:   The person is pleased to hear when chaos is created, or confusion emerges The person will take opportunities to create chaos or confusion The person enjoys taking part in chaotic or disorganized situations.   I can't seem to think of a word to describe the type of person who would act in this way.  I hope this question is clear.  EDIT: Below gbutters sums up nicely:     What I wonder is if there is a word for a generally good-natured person who just likes some good old-fashioned chaos. It seems like any person that thrives on chaos would have to have some extra baggage. Clearly if $\lambda$ is an eigenvalue of $A$ then $p(\lambda)$ is an eigenvalue of $p(A)$ where $p$ is a polynomial. And there are cases where $A$ may have eigenvalues other than these.   Is there a general rule for finding all eigenvalues of $p(A)$? Does it depend on the field from which the elements of $A$ are taken? Are their any partial solutions to this problem? Prove that $ S=\{0\}\cup\left(\bigcup_{n=0}^{\infty} \{\frac{1}{n}\}\right)$ is a compact set in $\mathbb{R}$, but $\bigcup_{n=0}^{\infty} \{\frac{1}{n}\}$ is not a compact set.   (Can we use definition of compact set for this problem? ) Windows 10 won't let me set default apps for file extensions Produce two distinct topologies of R such that the first is strictly finer than the second but the two are homeomorphic to each other. Need to prove that they are homeomorphic to each other.  So if T_1 and T_2 are topologies on set X with T_1 contained in T_2, every element of T_1 will be in T_2 and T_2 is the "finer" (stronger and larger) topology. So to them be homeomorphic is T_1 going to have to be a hole in T_2? Where did Hogwarts get money for salaries, food and other purchases? I've got a question about how to drive the car in Europe on Highways. In the US, I can overtake another car on either side, and I am fine.  In Europe I was told that I have to drive on the right side (Germany), and to overtake on the left side of the other driver.  Now I had following situation, and I did not know how to handle this properly: I was driving along on the right lane, the Autobahn was 3 lanes wide on my side, and was going around 110 km/h. Someone overtook me, but he stayed on the middle lane, and suddenly got slower. He wasn't really in front of me, so I could not change to the left lane, but I was told I may not overtake on the right side.  Would I have to brake in such a situation, or should I just ignore it, and overtake him again on the right side?  (I overtook him, and he was on the phone, so I guess that was why he got distracted and slowed down that much). Set Path for all Users (Login and Non-login Shells) Ok. So, I'm used to Ubuntu and CentOS more than redhat, so I'm hoping there's some obvious solution to this that I'm missing.  I've installed Anaconda (Python). I've placed it in:  /opt/anaconda3   I would like for myself and all users to be able to have the following in their paths:  /opt/anaconda3/bin   I have googled around and have gained a lot of conflicting information about how to "properly" accomplish my mission.  Stuff I have tried:   Adding a bash script to /etc/profile.d Editing /etc/profile Editing /etc/bashrc Adding to root bashrc Editing user .bashrc   All edits involved some form of:  PATH=/opt/anaconda3/bin:$PATH   or  export PATH=/opt/anaconda3/bin:$PATH   Option 2 yielded the addition of /opt/anaconda3/bin to the path for multiple users, but after terminal restarts still did not run the commands within bin (i.e. conda install, ipython notebook, etc.)  Any ideas? A loss and gain problem This is a very simple but confusing puzzle.  A customer buys goods worth $200$ rupees from a shop. The shopkeeper selling these goods makes zero profit from this purchase.  The lady gives him a $1000$ rupee note.  The shopkeeper has no change, so he goes next door to another shopkeeper to get change for the $1000$ rupee note. He keeps $200$ for himself and returns $800$ to the customer.  Later, the second shopkeeper from next door comes back with the $1000$ rupee note with a stamp on it saying "counterfeit" and takes his money back.  How much loss does the first shopkeeper face? What is the difference between "owing to" and "due to"? From 8th June there's been a  period for people entering the UK. From 10th July, travellers from  via a travel-corridor. If more countries are added to the list of exemptions then the date for each country will be later than the 10th July. If a traveller entered the UK from a country that is not on the exempt list and that country is added to the exempt list prior to the end of the 14 day self-isolation period does the self-isolation period end early? For example, if an individual entered the UK from France on the 5th July, should they remain in isolation for 14 days or does the isolation end on the 10th when France is added to the list of exempt countries? I think I'm being the victim of a bug here. Sometimes while I'm working (I still don't know why), my network traffic goes up to 200 KB/s and stays that way, even tough I'm not doing anything internet-related.   This sometimes happens to me with the CPU usage. When it does, I just run a top command to find out which process is responsible and then kill it. Problem is: I have no way of knowing which process is responsible for my high network usage. Both the resource monitor and the top command only tell me my total network usage, neither of them tells me process specific network info.  I've found questions here about monitoring total bandwidth usage, but, as I mentioned, that's not what I need. Is there another command I can use to find out which process is getting out of hand?  The command iftop gives results that disagree entirely with the information reported by System Monitor. While the latter claims there's high network traffic, the former claims there's barely 1 KB/s.  I've already tried killing all the obvious ones (Firefox, update-manager, Pidgin, etc) with no luck. So far, restarting the machine is the only way I found of getting rid of the issue.