Context  There is class 'A' which needs a lot of parameters. And there are classes B,C,D which depends D->C->B->A way. I have to set parameters for A while initializing D which would be passed on to C then to B, A. Now the problem is that the list of parameters is so big that it would be pain to pass each of it as argument in constructor. So instead I created a dictionary to pass it on by.  Question  In this case, is passing parameters with dictionary OK? If not, are there other way to solve this?
I'd like to call a function in python using a dictionary.  Here is some code:  d = dict(param='test')  def f(param):     print(param)  f(d)   This prints {'param': 'test'} but I'd like it to just print test.  I'd like it to work similarly for more parameters:  d = dict(p1=1, p2=2) def f2(p1, p2):     print(p1, p2) f2(d)   Is this possible?
The importance of a factor depends on how importance is defined.   The word importance has a fuzzy nature open to different   interpretations and the importance of a factor depends on how   importance is defined.      In other words, importance is ...   How can I complete this sentence with one word?   Edit:  I prefer to use a neutral word without negative connotations, since I'm not against having different interpretations in this case. Rather, I mean depending on how importance is defined, we need a different method. General relativity is expressed in terms of differential geometry, which allows you to do interesting things with the coordinates: multiple coordinates may refer to a single point, eg. the  has whole lines at the top and the bottom that correspond to the North and South poles, respectively; or a single coordinate may refer to multiple points, for example by using inverse geometry the origin refers to all the points infinitely far away.  So, is the singularity just a single point in the curved spacetime, or can it be a more extended object, described by a single coordinate? How can we prove that for every pair $N \in \mathbb{N}$, and natural number $\beta\in [2, \infty)$ there exists a unique set of integers $x_i \in [0, \beta -1]$, $k\in [0,\infty)$ such that:  $$N = \sum_{i=0}^{k}\beta^ix_{i}, \quad $$  It's a question if every positive integer has its unique representation in every base $\beta$. Is the validity of above statement somehow related to Horner's rule? Find all continuous functions satisfying $\int_0^xf=(f(x))^2+C$ for some constant $C \neq 0$. Find all continuous functions $f$ satisfying   $$\int_0^xf=(f(x))^2+C$$ for some constant $C \neq 0$, assuming that $f$ has at most one $0$.  I have a question about the solution to this problem. It says that   Clearly $f^2$ is differentiable everywhere, its derivative at $x$ is $f(x)$ (I'm assuming that this is because the left hand side is differentiable, the right hand side must be differentiable as well). So $f$ is differentiable at $x$ whenever $f(x) \neq 0$, and  $$f(x)=2f(x)f'(x),$$ so $f'(x) = \frac{1}{2}$ at such points. Thus, $f= \frac{1}{2}x+b$ for some $b$ on any interval where it is non-zero; if $f$ has a zero, this gives two possible solutions, with two possible values of $b$, but since $f$ is assumed continuous, they must be the same. So we need $$\int_0^x(\frac{1}{2}t+b)dt=(\frac{1}{2}x+b)^2+C$$  so we must have $b=\sqrt{-C}$ or $-\sqrt{-C}$, leading to two solutions for $C \lt 0$.  I don't understand the bolded statements. First, how does the differentiability of $f^2$ guarantee that $f$ is differentiable, and why only at $x$ where $f(x) \neq 0$?  Next, why are there two possible solutions if $f$ has a zero, but since $f$ is continuous they must be the same?  Finally, does the last statement mean that if $C \gt 0$, then there is no solution, since we're restricted to real numbers here?  I would appreciate it if anyone answers my questions. Tag scores are not updated and the issue is getting worse More often that I like to admit I look for a file that contains some strings.  Currently I do:  grep -rl string1 | xargs grep -l string2 | xargs grep -l string3   Is there a tool that does this prettier?  This greps for string1 or string2 or string3.   grep -rl -e string1 -e string2 -e string3   I want files that contain string1 and string2 and string3 but not necessarily on the same line.  Maybe one of the modern greps (ag/ack/rg/sift) can do this? Euclidean Algorithm for GCD of polynomials I am struggling to use the Euclidean algorithm for polynomials.  Given something like $$GCD(x^5+1, x^3+1)$$  I can easily use it as follows:   $$x^5+1 = x^2(x^3+1) -x^2 +1 \\ x^3+1 = -x(-x^2+1) + x +1 \\ -x^2+1 = (x+1)(-x+1)$$  GCD = x+1  But for something like $$GCD(2x^2+6x+3, 2x+1)$$   I cannot figure out how to do it using the same method. I start like this:  $$2x^2+6x+3 = x(2x+1) + 5x+3\\ 2x+1 = \frac{2}{5}(5x+3) - \frac{1}{5}\\$$  and I am not sure how to continue. Any help would be appreciated, sorry for my poor attempt at using LaTeX. How to convert a string of bytes into an int? 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. How to spawn a Giant with equipment? I really want to spawn Giant with armor and swords. Because Giants are strong, and great challenge if spawned with enchanted diamond armor and a diamond sword. Showing that $\Bbb R[x] / \langle x^2 + 1 \rangle$ is isomorphic to $\Bbb C$ question Show that $\Bbb R[x] / \langle x^2 + 1 \rangle$ is isomorphic to $\Bbb C$.      Let $\phi$ be the homomorphism from $\Bbb R[x]$ onto $\Bbb C$ given by   $f(x) \rightarrow f(i)$ (that is, evaluate a polynomial in $\Bbb R[x]$   at $i$).  Then $x^2 + 1 \in \operatorname{Ker} \phi$ and is clearly a   polynomial of minimum degree in $\operatorname{Ker} \phi$.  Thus,   $\operatorname{Ker} \phi = \langle x^2 + 1 \rangle$ and $\Bbb R[x] /\langle x^2 + 1 \rangle$ is isomorphic to $\Bbb C$.   My question is:  How is $x^2 + 1$ a polynomial of minimum degree in $\operatorname{Ker} \phi$? "Do you want to continue[Y/n]?" Why the upper case? I am new to Ubuntu and some little thing start to bug me. Such as when trying to install a program, Ubuntu asks,     Do you want to continue[Y/n]?   What is bugging me is why the letter "Y" is upper case and "n" is lower case. Do they have any significant reason why one is upper and the latter is lower? Whatever case I enter it doesn't change the outcome: it either continues or not. Are they trying to notify us that we can enter both and it won't change anything? I'm downloading some images from a service that doesn't always include a content-type and doesn't provide an extension for the file I'm downloading (ugh, don't ask).  What's the best way to determine the image format in .NET?  The application that is reading these downloaded images needs to have a proper file extension or all hell breaks loose. We're in the process of deploying a private openstack instance but don't have the Swift object storage service available yet. Can juju bootstrap launch a utility instance without swift? I see that the openstack configuration control-bucket is a container id. Find $f(x)$ for $f(f(x))=\sin x$ Find all (if that's possible) functions $f:\mathbb{R}\rightarrow\mathbb{R}$ such that $$f(f(x))=\sin x.$$  This is a problem a friend gave me. He said he saw it on a book a long time ago, but he couldn't remember what book. I literally have no idea how to solve this so I can't post my attempt here. I have a simple skull model, to which I applied the subdivision modifier. For the most part everything works as expected, except I keep getting these weird sharp vertices and I can't seem to figure out how to flatten them.    I'm using Blender 2.8. Is this some kind of feature I can disable/enable for particular vertices? The distance between the sharp vertices and the gray outline differ.    Any suggestions please? Thank you!  EDIT: I also tried selecting as both - vertexes and edges and then applied Edge->Clear Sharp, but nothing changed. How to measure time taken by a function to execute I need to get execution time in milliseconds.  I originally asked this question back in 2008. The accepted answer then was to use  However, we can all agree now  that using the standard  API is more appropriate. I am therefore changing the accepted answer to this one. Sending email in .NET through Gmail SElinux: allow httpd to connect to a specific port My system is running CentOS 6.4 with apache2.2.15. SElinux is enforcing and I'm trying to connect to a local instance of redis through my python/wsgi app. I get Error 13, Permission denied. I could fix this via the command:  setsebool -P httpd_can_network_connect  However, I don't exactly want httpd to be able to connect to all tcp ports. How can I specify which ports/networks httpd is allowed to connect to? If I could make a module to allow httpd to connect to port 6379 ( redis ) or any tcp on 127.0.0.1, that would be preferable. Not sure why my paranoia is so strong on this, but hey...  Anyone know? Conflict between tkz-fct and thmtools? Is PCA unstable under multicollinearity? I know that in a regression situation, if you have a set of highly correlated variables this is usually "bad" because of the instability in the estimated coefficients (variance goes toward infinity as determinant goes towards zero).  My question is whether this "badness" persists in a PCA situation.  Do the coefficients/loadings/weights/eigenvectors for any particular PC become unstable/arbitrary/non-unique as the covariance matrix becomes singular?  I am particularly interested in the case where only the first principal component is retained, and all others are dismissed as "noise" or "something else" or "unimportant".  I don't think that it does, because you will just be left with a few principal components which have zero, or close to zero variance.  Easy to see this isn't the case in the simple extreme case with 2 variables - suppose they are perfectly correlated.  Then the first PC will be the exact linear relationship, and the second PC will be perpindicular to the first PC, with all PC values equal to zero for all observations (i.e. zero variance).  Wondering if its more general.