I have this code in my python script  class Class(object):     client_id = ''      @classmethod     def get_client_id(cls):         return cls.client_id   class Service(object):      @staticmethod     def get_class():         cls_obj = Class()         cls_obj.client_id = 'this is client id'         return cls_obj  print(Service.get_class().get_client_id())   but when i run the python script, it displays empty string and not the 'this is client id'. please help
Is there any meaningful distinction between:  class A(object):     foo = 5   # some default value   vs.  class B(object):     def __init__(self, foo=5):         self.foo = foo   If you're creating a lot of instances, is there any difference in performance or space requirements for the two styles? When you read the code, do you consider the meaning of the two styles to be significantly different?
What happens to the view.frame.size attribute after a CGAffineTransform (Rotate)? Review Audit failed when "late answer" answer is a duplicate I just got a review audit where the "late answer" was a duplicate of the accepted answer, but flagging it on that basis failed the review. That seems like a bug to me.  Question here:   I found that by clicking the question to view the entire Q&amp;A, and noticed that the copy was from a generic "user12345" account (probably with 1 rep as well) and the original from a real-looking account. Viewing the whole Q&amp;A is often useful when reviewing, especially late answers (which are often repeats of earlier points, disagreements with those, or random addendums better submitted as edits). I looked at the duplicate and thought "weird, rep harvesting maybe?" so I clicked "needs moderator attention" and wrote "copy and paste of accepted answer". FAIL!  I think that this review type can't ever work, because to avoid the problem I found you'd need to make up whole new "late answers" which by definition the review bot can't know anything useful about. Either that or to pass you'd just need to take any action at all, including upvoting the original of the duplicated answer. Which I didn't do, BTW, because I had no idea or opinion about the question or answer.  (this is not a duplicate of "What are review tests", it predates that and focuses on a particular defect within the process. See the comments below). And when I tried the following commands /etc/hostnames and /etc/hosts, it says:  bash: permission denied. Can I watch the progress of a `sync` operation? I've copied a large file to a USB disk mounted on a Linux system with async. This returns to a command prompt relatively quickly, but when I type sync, of course, it all has to go to disk, and that takes a long time.  I understand that it's going to be slow, but is there somewhere where I can watch a counter go down to zero? Watching buffers in top doesn't help. It is a theorem in elementary number theory that if $p$ is a prime and congruent to 1 mod 4, then it is the sum of two squares. Apparently there is a trick involving arithmetic in the gaussian integers that lets you prove this quickly. Can anyone explain it? Explanation that air drag is proportional to speed or square speed? A falling object with no initial velocity with mass $m$ is influenced by a gravitational force $g$ and the  (air resistance) which is proportional to the object's speed. By Newton´s laws this can be written as:   $mg-kv=ma$ (for low speeds)  $mg-kv^2=ma$ (for high speeds).    I assume that $k$ is a positive constant that depends on the geometry of the object and the viscosity. But how can one explain that the air resistance is proportional to the velocity? And to the velocity squared in the second equation? Count and limit the number of files uploaded (HTML file input) How to round a number to n decimal places in Java What I would like is a method to convert a double to a string which rounds using the half-up method - i.e. if the decimal to be rounded is 5, it always rounds up to the next number. This is the standard method of rounding most people expect in most situations.  I also would like only significant digits to be displayed - i.e. there should not be any trailing zeroes.  I know one method of doing this is to use the String.format method:  String.format("%.5g%n", 0.912385);   returns:  0.91239   which is great, however it always displays numbers with 5 decimal places even if they are not significant:   String.format("%.5g%n", 0.912300);   returns:  0.91230   Another method is to use the DecimalFormatter:  DecimalFormat df = new DecimalFormat("#.#####"); df.format(0.912385);   returns:  0.91238   However as you can see this uses half-even rounding. That is it will round down if the previous digit is even. What I'd like is this:  0.912385 -&gt; 0.91239 0.912300 -&gt; 0.9123   What is the best way to achieve this in Java? How to check if list item already exist when adding it with how to check Title( Country) if exists in the list. if exists it is necessary to do the update if not it is necessary to add it ?  function AddListItem() {      var listTitle = "Test";     //Get the current client context       context = SP.ClientContext.get_current();     var airportList = context.get_web().get_lists().getByTitle(listTitle);          //Create a new record       var listItemCreationInformation = new SP.ListItemCreationInformation();     var listItem = airportList.addItem(listItemCreationInformation);      //Set the values      var country= $("#Country").val();     var client= $("#Client").val();     // var nb1 = $("#nb1").val();      // var nb2 = $("#nb2").val();       // var nb3 = $("#nb3").val();      // var nb4 = $("#nb4").val();       // // var nb5 = $("#nb5").val();        listItem.set_item('Country', Country);     listItem.set_item('Client', Client);     listItem.update();     context.load(listItem);     context.executeQueryAsync(AddListItemSucceeded, AddListItemFailed); } function AddListItemSucceeded() { } function AddListItemFailed(sender, args) {     alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); } When I input [asdf][lisp] into the search field on , without being logged in, only one tag remains. Is it broken? How to select lines between two marker patterns which may occur multiple times with awk/sed How should I take care of my new DSLR? I am getting a new Nikon D5100 (with 18-55mm VR Lens Kit). This is going to be my first DSLR. I wanted to get some tips from you guys on how to maintain it in the long term. I am getting a 52mm UV Protector Filter, as I read that it would do well to keep the lens clean.  Are there any precautions I need to take?  I would also appreciate if someone can suggest some reading material (paperback or online). Three linked question on non-negative definite matrices. 1.a symmetric matrix in $\mathbb{M}_n(\mathbb{R})$ is said to be non-negative definite if $x^Tax≥0$ for all (column) vectors $x\in \mathbb{R}^n$. Which of the following statements are true? (a) If a real symmetric $n\times n$ matrix is non-negative definite, then all of its eigenvalues are non-negative. (b) If a real symmetric $n\times n$ matrix has  all of its eigenvalues are non-negative , then it is non-negative definite. (c) If $ A\in \mathbb{M}_n(\mathbb{R})$, then $AA^T$ is non-negetive definite. 2. only one of the following matrices is non-negetive definite. Find it. (a) $\begin{pmatrix} 5 &amp; -3 \\ -3 &amp; 5 \end{pmatrix}$. (b) $\begin{pmatrix} 1 &amp; -3 \\ -3 &amp; 5 \end{pmatrix}$. (c) $\begin{pmatrix} 1 &amp; 3 \\ 3 &amp; 5 \end{pmatrix}$.      3.let $B$ be the real symmetric non-negative definite $2×2$ matrix such that $B^2=A$ where $A$ where is the non-negetive definite matrix in question $2$.write down the characteristic polynomial of $B$.      My thoughts..  For1.  (a) &amp; (b) are true but not sure about (c). For 2. (a) is the correct option since it has all positive eigen values.they are $2,8$. For 3. Eigen values of $B$ will be $\sqrt{2}$ and $\sqrt{8}$. So the answer is $x^2-3√2x+4=0$.      Can anybody help me to verify the solutions of the above problems. How many roots have a complex number with irrational exponent? If a rational exponent on a complex number $z^q$ is the representation of a finite number of roots, then if the exponent is irrational this mean that there is infinite countable roots?  If this is the case... the cardinality of the number of roots is the same for any irrational exponent? Thanks in advance.  NOTE: there are different questions about irrational exponents but no one answer what Im searching so please dont mark this as repeated. Should I vote to close a duplicate question, even though it's much newer, and has more up to date answers? I have seen this many times, a question is being asked because a previous, duplicate question was asked and answered a few years ago and has no longer relevant answers.  The  is to edit the old question, or add new answers to it, but it is not always happening.  I was wondering, should I still mark it as duplicate and vote to close it? Or just leave it as is? I was given a MySQL database file that I need to restore as a database on my Windows Server 2008 machine.  I tried using MySQL Administrator, but I got the following error:     The selected file was generated by   mysqldump and cannot be restored by   this application.   How do I get this working? I was writing some Unit tests last week for a piece of code that generated some SQL statements.  I was trying to figure out a regex to match SELECT, INSERT and UPDATE syntax so I could verify that my methods were generating valid SQL, and after 3-4 hours of searching and messing around with various regex editors I gave up.  I managed to get partial matches but because a section in quotes can contain any characters it quickly expands to match the whole statement.  Any help would be appreciated, I'm not very good with regular expressions but I'd like to learn more about them.  By the way it's C# RegEx that I'm after.  Clarification  I don't want to need access to a database as this is part of a Unit test and I don't wan't to have to maintain a database to test my code. which may live longer than the project. How do you differentiate the likelihood function for the uniform distribution in finding the M.L.E.? There is a classic problem:  Suppose that $X_1,\ldots,X_n$ form an i.i.d. sample from a uniform distribution on the interval $(0,\theta)$, where $\theta&gt;0$ is unknown. I would like to find the MLE of $\theta$.  The pdf of each observation will have the form: $$ f(x\mid\theta) =  \begin{cases} 1/\theta\quad&amp;\text{for }\, 0\leq x\leq \theta\\ 0 &amp;\text{otherwise}. \end{cases} $$ The likelihood function therefore has the form: $$ L(\theta) = \begin{cases} 1/\theta^n \quad&amp;\text{for }\; 0\leq x_i \leq \theta\;\; \text{for all }i,\\ 0 &amp;\text{otherwise}. \end{cases} $$ The general solution is usually that the MLE of theta must be a value of $\theta$ for which $\theta \geq x_i$ and which maximizes $1/\theta^n$ among all such values.   The reasoning is that since $1/\theta^n$ is a decreasing function of $\theta$, the estimate will be the smallest possible value of $\theta$ such that $\theta\geq x_i$.  Therefore, the mle of $\theta$, $\hat{\theta}$, is $\max(X_1,\ldots,X_n)$.  Here, I do not understand why we cannot just differentiate the likelihood function with respect to theta and then set it equal to $0$?  Thanks! grep strange behaviour with single letter words I am removing stop words from a text, roughly using this   I have the following  $ cat file file types extensions  $ cat stopwords i file types   grep -vwFf stopwords file  I am expecting the result: extensions  but I get the ( I think incorrect)  file extensions   It is as if the word file has been skipped in the stopwords file. Now here's the cool bit: if I modify the stopwords file, by changing the single word/letter i on the first line, to any other ascii letter apart from f, i, l, e, then the same grep command gives me a different and correct result of extensions.  What is going on here and how do I fix it?  I'm using grep (BSD grep) 2.5.1-FreeBSD on a Mac OSX GNU bash, version 4.4.12(1) I know that who is used when asking about a subject (Who is at the door?) and whom is used when asking about an object (By whom was the door opened?). How do you determine which one to use when the object becomes the subject of another clause?   For example, take the sentence:      I gave the prize to ____ deserved it most.   Would it be whomever because it's the object of "gave," or would it be whoever because it's the subject of "deserved"? Is their a hard-and-fast rule to rely on in situations like this?