combining raw strings with non raw string I want to combine a raw string with a non raw one which should be a user input (direct input or config file extracted variable), in order to combine them into a regular expression;  import re input = "user_input" regex = re.compile(r"^line:{}.\s(group_to_be_captured)".format(input)   The problem is that user_input contains parenthesis then     regex.pattern   is equal to     '^line:userinputpart1(userinputpart2).\\s(group_to_be_captured)'   so \s has its slash escaped normally, but the parentheses in userinput are not escaped which is thus inconvenient since are recognized as groups to retrieve and not as characters. I know that I indeed can replace them by escaped parentheses using re.sub or str.replace but it made me wonder if there is a simple mean to combine raw strings with non raw ones or if there is some format parameter I am missing ?
Escaping regex string I want to use input from a user as a regex pattern for a search over some text.  It works, but how I can handle cases where user puts characters that have meaning in regex? For example, the user wants to search for Word (s): regex engine will take the (s) as a group.  I want it to treat it like a string &quot;(s)&quot; .  I can run replace on user input and replace the ( with \( and the ) with \) but the problem is I will need to do replace for every possible regex symbol. Do you know some better way ?
Newton's cradle Why, when one releases 2 balls in , two balls on the opposite side bounce out at approximately the same speed as the 1st pair, rather than one ball at higher speed, or 3 balls at lower speed? I have an iPhone with 100+ notes that I've collected over the last ten years (thanks to migrating from my PalmPilot). I realize that I can now synchronise these with Gmail, but that doesn't allow me to edit them from my computer. I'd rather switch to use a new app/website combo which allows for online editing of notes, automatic OTA syncing, etc.  It seems like Simplenote and Evernote are two of the better app/sites, as mentioned at  and from this , I think Simplenote is exactly what I'm looking for. The problem is, I can't figure out how to migrate all of my existing notes into whatever new notes app I choose.  How do I migrate my existing Apple iOS Notes into Simplenote or Evernote?  The best workaround I've found so far is to open each note, select all, copy, and create a new note in the iOS app but I'd rather not spend the time and hassle doing this for ~100 notes. Groups of order $pq$ without using Sylow theorems If $|G| = pq$,  $p,q$ primes, $p \gt q, q \nmid p-1 $, then how do I prove $G$ is cyclic without using Sylow's theorems? Does anyone know of any linux tool specifically designed to treat files as sets and perform set operations on them? Like difference, intersection, etc? Getting raw SQL query string from PDO prepared statements Is there a way to get the raw SQL string executed when calling PDOStatement::execute() on a prepared statement? For debugging purposes this would be extremely useful. What's the fixed size of the suggested edit queue? Evaluating string "3*(4+2)" yield int 18 Methods to work around the problem of missing data in machine learning UnboundLocalError: local variable 'url_request' referenced before assignment Consider the atomic spectrum (absorption) of hydrogen.     The Bohr's model postulates that there are only certain fixed orbits allowed in the atom. An atom will only be excited to a higher orbit, if it is supplied with light that precisely matches the difference in energies between the two orbits.   But how precise does 'precisely' mean. Of course, if we need energy $E$ to excite the electron to a higher energy level, and I supply a photon with just $E/2$ I would expect nothing to happen (since the electron cannot occupy an orbit between the allowed ones). But what if I supplied a photon with energy $0.99E$, or $1.0001E$ or some such number. What will happen then?  I think that the electron should still undergo excitation precisely because the lines we observe in the line spectrum have some thickness. Which means that for a given transition, the atom absorbs frequencies in a certain range.   Is my reasoning correct? If not, why? How does Bohr's model explain this? How about modern theory?   If I'm right, what is the range of values that an atom can 'accept' for a given transition? "...would have trouble imagining...": Is this present participle or gerund? Is there an alternative way to express "has them " other than "makes them "? For example, in the following sentence, can I replace have them with makes them, or is there another verb that more correctly I could use instead of has?     Since the manufacturers are so deeply involved, in some cases Wal-Mart even has them handle their own distribution, saving the retailer big bucks and increasing profit margins on cheaper goods.   Another example could be the following one.     The doctor sends my father and Uncle Johnnie out for all the ice they can get. Then he has them dump the ice in the bathtub, add cold water almost to the top, whereupon my aunt is wrestled into the tub and submerged. How do you prove the second law of thermodynamics from statistical mechanics? What did the public at large know about the assassination attempt on Palpatine and how he survived it? Do we have more history for cd? I have a vector space $V$ over a field of characteristic $0$. If $M_1,\dots,M_k$ are proper subspaces of $V$, and $N$ is a subspace of $V$ such that $N\subseteq M_1\cup\cdots\cup M_k$, how can you tell $N\subseteq M_i$ for some $i$?  I was first trying to show it just in the case $N\subseteq M_1\cup M_2$, and hoping to extend it to finitely many $M_i$. If either of the $M_i$ contains the other, the claim follows, so I suppose neither $M_i$ contains the other.   In hopes of a contradiction, I suppose $N\not\subseteq M_1$ and $N\not\subseteq M_2$, Picking $x_1\in N\setminus M_1$ and $x_2\in N\setminus M_2$, I'd have $x_1+x_2\in N\subseteq M_1\cup M_2$. The only thing I could conclude was that actually $x_1,x_2\notin M_1$ and $x_1,x_2\notin M_2$, which seems like a dead end. What's the right way to do this? Applications Don't Show Up in Spotlight Spotlight has stopped showing any results for my Applications. I've tried reindexing and removing the index so it rebuilds it. No change. I've tried adding Applications to the Privacy tab and removing it, no change.  I tried repairing disk permissions and redoing the above, no change. I've tried removing everything from the index except Applications and then I just get nothing for any search at all (except dictionary entries).  I tried adding a symlink in my homedir to Applications and reindexing, but no change.  Any ideas on what to do?  I'm running Snow Leopard.  This is driving me crazy!  Update: I've noticed that when I start a reindex with sudo mdutil -E / and then immediately do a Spotlight search for an app that the app shows up temporarily until Spotlight gets disabled due to active indexing.  After the indexing is done, the app entries go away. PHP - Get rid of notation I am currently using a MacBook Pro 13&quot; Mid 2018 with Touch Bar. Today macOS Big Sur was released and I tried to download it but it's getting stuck at 484.4 MB. Initially, it shows 16-17 minutes left, but as soon as it reaches 484.4 MB it's stuck and the timer goes till 10 hours! My Wi-Fi is totally stable with a speed of 100 Mbps. I tried to restart my Mac but it still gets stuck. Earlier there were similar issues in the App Store (even now they are). The issue was I was not able to download an app unless I connect to the US VPN. I even contacted support but they were not able to help out. It wasn't a big deal as a VPN could be used. But now even with VPN, it gets stuck. resolv.conf not working properly with Ethernet in Ubuntu I have a Lenovo X200 laptop on which I am running Ubuntu 9.10. Recently, (I assume after some updating, but I really don't know) my ethernet port stopped working under Linux. A more tech/linux-savvy friend of mine was able to temporarily fix the problem by manually editing the resolv.conf file with the DNS servers he found through his connection. However, after rebooting, the problem came back and now I am looking for a more permanent solution.