The import cannot be resolved in eclipse
Eclipse error: "The import XXX cannot be resolved"
I have embedded a Python interpreter in a C program.  Suppose the C program reads some bytes from a file into a char array and learns (somehow) that the bytes represent text with a certain encoding (e.g., ISO 8859-1, Windows-1252, or UTF-8).  How do I decode the contents of this char array into a Python string?  The Python string should in general be of type unicode—for instance, a 0x93 in Windows-1252 encoded input becomes a u'\u0201c'.  I have attempted to use PyString_Decode, but it always fails when there are non-ASCII characters in the string.  Here is an example that fails:  #include &lt;Python.h&gt; #include &lt;stdio.h&gt;  int main(int argc, char *argv[]) {      char c_string[] = { (char)0x93, 0 };      PyObject *py_string;       Py_Initialize();       py_string = PyString_Decode(c_string, 1, "windows_1252", "replace");      if (!py_string) {           PyErr_Print();           return 1;      }      return 0; }   The error message is UnicodeEncodeError: 'ascii' codec can't encode character u'\u201c' in position 0: ordinal not in range(128), which indicates that the ascii encoding is used even though we specify windows_1252 in the call to PyString_Decode.  The following code works around the problem by using PyString_FromString to create a Python string of the undecoded bytes, then calling its decode method:  #include &lt;Python.h&gt; #include &lt;stdio.h&gt;  int main(int argc, char *argv[]) {      char c_string[] = { (char)0x93, 0 };      PyObject *raw, *decoded;       Py_Initialize();       raw = PyString_FromString(c_string);      printf("Undecoded: ");      PyObject_Print(raw, stdout, 0);      printf("\n");      decoded = PyObject_CallMethod(raw, "decode", "s", "windows_1252");      Py_DECREF(raw);      printf("Decoded: ");      PyObject_Print(decoded, stdout, 0);      printf("\n");      return 0; } A method for the OP to accept comments? Question: What if the author of a question can accept a comment?   The problem:  Time and time again, answers are posted as a comment.  Usually, the person who commented has the best of intention (e.g. it was a trivial answer [to the answerer], and they weren't sure if the OP would immediately edit the question after the comment).  But this leaves the frustrating situation of an unanswered question with a perfectly good answer.  This problem accumulates over the years.     Candidate solution:  The OP can just "accept" the comment, after which a duplicate of the comment is made an accepted CW answer, with a preface indicating that it was originally a comment, e.g. This answer was originally a comment posted by [[blah]] that has been accepted by the author of the question.   Comments on this scheme:   The author of the comment has indicated they're not interested in gaining/losing reputation through their comment (thus CW answer). The original comment is still there. If desirable, the "author" of the accepted question could be a "bot", so the answer is not attributed to a genuine account.  (I suppose it would already be technically possible for Joe Blow to create a script for a bot that creates an answer from a comment in the proposed way.)     A similar question was asked before  (over 3 years ago), and in numerous other questions which have been deemed "duplicates" (,  and ; see also ), so there seems to be demand for such a feature.  The answers to these questions seem (to me, at least) quite weak:   "ask the commenter to add the comment as an answer"   The OP already did this by asking the question in the first place.  And what if the author of the comment doesn't respond (or takes a long time to respond)?  This also adds more chit-chat irrelevant to the question.   "add an answer of your own, referring to the comment, and accept it."   A hacky workaround.  How could this possibly be better than accepting a comment?  (Yet, this is the most up-voted response.)  Moreover, this adds to the user's list of "answers" (thus making the user's page harder to look through).   "When i leave a comment, i do so because i want to leave a comment."   Great; now what about everyone else?  In the immortal words of the FAQ: "Other people can edit my posts?!"  And it's not even an edit, it's copying the post from one box to another (a more hacky version of which is regarded as the "accepted" method). iCloud Drive is stuck uploading items and no longer syncs I got the macOS Sierra update when it went into public beta, and I've been trying to use the automatic .  I've enabled the feature, however since September 7 no files have been uploaded. By this point, the bottom of my Finder windows say:     15.78 GB available on iCloud, uploading 156,106 items (543.2 MB of 543.2 MB)   However the files are never actually uploaded. I keep my screenshots folder on my desktop and I take a lot of screenshots, so I can see that September 7 was the last date any file was actually uploaded.  What should I do? Is there a way I can disable and re-enable the feature without risking loss of data? Are there any solutions to this problem? What should I try? So far I've tried rebooting, and tried software update to macOS 10.12.2 public beta. How to extract the n-th elements from a list of tuples? L293, L298 and SN754410 H-bridge drivers on low voltage power supply This question is about the following three integrated H-bridge drivers: -    or L293D (D = protection diodes added)  (protection diodes included)  (no protection diodes)   Time after time the same question keeps coming up - someone is using one of these devices (on a low voltage, usually around 6V or less) and they are just not performing adequately. The reasons are listed further below but my question is this: -  What H-bridge drivers are preferred when controlling a low-voltage motor?   Information  The L293 and the SN754410 are nearly identical and crucially, if you try and control a 1 amp load, you are faced with dismal performance: -    The tables tell you (typical conditions) that the upper transistor drops (loses) about 1.4 volts when driving a 1A load and, the lower transistor drops (loses) about 1.2 volts when driving a 1A load. The upshot is that if you have a 6V, 1A motor and 6V battery, don't expect to see more than 3.4 volts across the motor: -  \$V_{OUT} = 6V - (1.4V + 1.2V) = 3.4V\$  Worst case scenario is you might only see 2.4 volts across it.  What about the L298? It's got a nice big heat-sink whereas the L293 and SN754410 are regular-looking chips. Here's what the volt drop (losses) look like: -    It's the same story - for a 1A load, you can expect to lose up to 3.2 volts and, what you thought might be 6V across your motor, is at best 4.2 volts and at worst only 2.8 volts.  Clearly none of the devices listed are suitable for low voltage applications where the motor might be expected to draw in excess of 0.5 amps. I'm having trouble applying a patch to my source tree, and it's not the usual -p stripping problem. patch is able to find the file to patch.  Specifically, my question is how to read / interpret the .rej files patch creates when it fails on a few hunks. Most discussions of patch/diff I have seen don't include this. How to make a meta box field a requirement Why are my sauces splitting? Efficiency of a heat pump water heater during the winter In my understanding, heat pump water heaters pump energy from the room around the water tank into the water.  Clearly, this must be energy efficient in the summer time, especially if I am using AC anyway. The heat pump water heater may actually cool the house a bit.  However, in the winter time the savings are not so obvious. If I am using a heater to heat the home, including the water tank room, then I don't see how there can be any savings. Instead of generating heat using a coil in the water, I generate heat in another area of the house which gets pumped into the water. A joule is a joule and I need to get it from somewhere. It seems to me that if I am actively heating the house, and lets assume everything is electric, then a heat pump water heater cannot be more efficient than a traditional one.  Am I missing something in the winter case? How long was Luke Skywalker's training with Yoda? From the answer to the question  :     We also don't know how much time Luke spent training.   I tried to check some references like  and  related section on their Wookieepedia articles, but there is not even a clue of the amount of time he spent there.  Is there any canon information on the subject? Or any extrapolation of how long Luke's journey on Dagobah was? Was it a day? Several weeks? Some months? Existence of the moment generating function and variance Near Earth vs Newtonian gravitational potential Newton's Law of Universal Gravitation tells us that the potential energy of object in a gravitational field is $$U ~=~ -\frac{GMm}{r}.\tag{1}$$  The experimentally verified near-Earth gravitational potential is  $$U ~=~ mgh.\tag{2}$$  The near-Earth potential should be an approximation for the general potential energy when $r\approx r_{\text{Earth}}$, but the problem I'm having is that they scale differently with distance.  $(1)$ scales as $\frac 1r$.  So the greater the distance from the Earth, the less potential energy an object should have.  But $(2)$ scales proportionally to distance.  So the greater the distance from the Earth, the more potential energy an object should have.  How is this reconcilable? Where to or how to ask "Best of" Questions for what software tools to use I am wondering where is a good place or how is a good way to ask a question on what software tools to use for a specific task.  A lot of the time when searching for information on these types of problems stackoverflow comes up with the top and actually useful discussions and answers, but the question is locked.  I completely understand the point of discouraging "best of" or list questions as discussed in this question () and agree they often aren't constructive enough to justify the effort in moderating them.  What I am wondering is where is the right place to have a discussion like this? Stackoverflow has a good and active community so perhaps there is another section or related site I can ask less specific questions. And I do find some value in reading people's opinions, even if subjective on issues like this.  Here are some examples of the kind of questions I mean:    and   First results in google when searching for those subjects and some useful discussion.  Perhaps asking a question like this but with a strict and detailed specification it might be considered a valid and reasonable question to ask on stackoverflow; perhaps it's just a case of re-thinking how to ask a question. Or perhaps there's a more relevant place for this kind of discussion. Please let me know what you think. I'm an android developer and have laptop with 4GB RAM. When I compile my project the RAM is used at 100%.    If I add more RAM will it solve the problem? If $k$ is a positive integer, how to prove that there is no solution for $n$ in positive integers except $n = 1$ for $2^n = nk + 1$ Command for creating a directory and navigating into it directly? Disappointed to see that the 18.04 installer no longer offers the option to encrypt the home directory. According to  bug report referenced in the installer, the recommended method for encryption these days is full-disk with LUKS, or fscrypt for directories. Full-disk encryption seems a bit overkill for my needs, and all the bugs and caveats mentioned on the  don't make it a very attractive option. All I really want is to protect my home directory from someone accessing my documents, photos, etc. if my laptop were to get stolen, making fscrypt the option for me.  The  has some examples on how to set it up, but I can't find any documentation aimed at encrypting the home directory on Ubuntu. The old ecryptfs tool is still available, but after setting it up Ubuntu would sometimes freeze at the login screen.  So my question is: How do I setup fscrypt to encrypt my /home directory and decrypt when I log in? I also liked how ecryptfs allowed decrypting the folder manually (eg. from disk images).  (A similar question was posted  and was unfortunately closed for being an "off-topic" bug report. To clarify, this is not a bug report. The fact that the encrypt home directory option was removed from the installer was intentional. All I'm asking here is how to setup fscrypt.) How to make the taskbar blink my application like Messenger does when a new message arrive? How can we prove charge invariance under Lorentz Transformation? How do I install VMware player on a Mac os X? I went to their site, and downloaded a .bundle which automagically turned into a .txt file after downloading.   Long story short, I can't run the txt file because I guess Mountain Lion Mac os X isn't a strict Linux box and is missing some core components to do that type of installation.  Does anyone know how to install VMware?