I need to forward a dictionary to another function (that I can't change). Both my function and the target function look like this:  def myFunc(arg, **args): def targetFunc(arg, **args):   In my code, I used to call the target function directly:  a = targetFunc(123, aaa=4, bbb=5, ccc=6)   and I have to add another layer to process the extra arguments passed as a dictionary, before forwarding to the target function:  a = myFunc(123, aaa=4, bbb=5, ccc=6)   And now my function receives 123 as arg, and a dictionary:  {'bbb": 5, 'ccc': 6, 'aaa': 4}   as args. The problem is, I can't modify the target function in any way. It may be a function from a package like subprocess.run. I've tried supplying the dictionary directly but Python says  def myFunc(arg, **args):     print(args)     targetFunc(arg, args)  def targetFunc(arg, **args):     print(args)     TypeError: targetFunc() takes 1 positional argument but 2 was given   I can write myFunc in any way. How can I forward this dictionary to the target function, so it receives the same dictionary as its args?  Note: It's possible to construct a string then eval() it, but I don't want to do it that way.
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?
I want to match a portion of a string using a  and then access that parenthesized substring:  var myString = "something format_abc"; // I want "abc"  var arr = /(?:^|\s)format_(.*?)(?:\s|$)/.exec(myString);  console.log(arr);     // Prints: [" format_abc", "abc"] .. so far so good. console.log(arr[1]);  // Prints: undefined  (???) console.log(arr[0]);  // Prints: format_undefined (!!!)   What am I doing wrong?    I've discovered that there was nothing wrong with the regular expression code above: the actual string which I was testing against was this:  "date format_%A"   Reporting that "%A" is undefined seems a very strange behaviour, but it is not directly related to this question, so I've opened a new one, .    The issue was that console.log takes its parameters like a printf statement, and since the string I was logging ("%A") had a special value, it was trying to find the value of the next parameter. Faithful group actions for singleton group or for empty set Let $G$ be a group, possibly a singleton. Let $M$ be a set, possibly empty. Let $\mu: M \times G \to M$ be a right group action. Let $1_G$ be the identity of $G$.  I understand 's second definition of faithful as follows:     $\mu$ is faithful if for each $g \in G$ such that $g \ne 1_G$, there exists $x \in M$ such that $\mu(x,g) \ne x$. $\tag{1}$   Later  says if $\mu$ is free and $M$ is a non-empty set, then $\mu$ is faithful.  Question: Given the idea that we can have $M$ as an empty set, I would like to clarify: Are these correct?   If $G$ is a singleton, then every action $\mu$ is faithful, whether or not $M$ is empty. If $G$ is not a singleton, but $M$ is empty, then every action $\mu$ is not faithful. Continuing enumerate Counters in Beamer I'm trying to continue the numbering of examples in enumerate environments in beamer. For example, I'd like one slide to feature   Foo Bar   and the next slide   Zip Yadda   My strategy so far has been to define a counter that saves the enumerate counter at the end of the first environment and can then be queried to set the enumerate counter at the start of the second enumerate environment. (This is essentially the proposal also found at )  That works wonderfully so long as I don't try to uncover elements of the slide sequentially. The problem, of course, is that as each of the pdf-pages that make up the slide is created, the counter is advanced. Here's a MWE.  \documentclass{beamer}  \setbeamercovered{highly dynamic}  \newcounter{saveenumi} \newcommand{\seti}{\setcounter{saveenumi}{\value{enumi}}} \newcommand{\conti}{\setcounter{enumi}{\value{saveenumi}}}   \begin{document}  \begin{frame}[&lt;+-&gt;]   \begin{enumerate}   \item foo   \item bar%     \seti   \end{enumerate} \end{frame}  \begin{frame}[&lt;+-&gt;]   \begin{enumerate}     \conti   \item zip   \item yadda%     \seti   \end{enumerate} \end{frame}  \end{document}   As the second slide is progressively uncovered (pages 3 and 4 of the resulting PDF), the counter at the beginning of the enumerate environment is advanced each time. So page 3 of the PDF has the right numbering, (3) and (4) respectively, while the fully revealed page has the wrong numbering. Pictures follow:   on one of the slides    on the following one When should I use "when" and "while"? But you can't find anything while you're crying.   But you can't find anything when you're crying.   I'll tell you about it while Frank saddles the horse.   I'll tell you about it when Frank saddles the horse.     When should I use when, and when while? Are these sentences correct? Ubuntu has been crashing on me recently. I think its because it runs out of memory so I ran the free -m command and found that my memory usage was really high. So then, i ran top to find the culprit, but the displayed processes were using less than 1.5% of memory. How do I know which program is making ubuntu crash/run out of memory? Below is the output:  shafee@shafee-pc:~$ free -m              total       used       free     shared    buffers     cached Mem:          3824       3714        110          0        978       1954 -/+ buffers/cache:        780       3044 Swap:           99          0         99  shafee@shafee-pc:~$ top top - 02:12:14 up  1:24,  2 users,  load average: 0.16, 0.42, 1.49 Tasks: 182 total,   1 running, 181 sleeping,   0 stopped,   0 zombie Cpu(s):  2.9%us,  1.9%sy,  0.3%ni, 79.3%id, 15.5%wa,  0.0%hi,  0.2%si,  0.0%st Mem:   3916708k total,  3803848k used,   112860k free,  1002308k buffers Swap:   102396k total,        0k used,   102396k free,  2001852k cached    PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND              4200 root      20   0  289m  53m  38m S    2  1.4   1:06.45 Xorg                 5590 shafee    20   0 19348 1368  956 R    2  0.0   0:00.01 top                     1 root      20   0 24124 2136 1264 S    0  0.1   0:02.05 init                    2 root      20   0     0    0    0 S    0  0.0   0:00.00 kthreadd                3 root      20   0     0    0    0 S    0  0.0   0:24.23 ksoftirqd/0             6 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/0             7 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/1             9 root      20   0     0    0    0 S    0  0.0   0:00.11 ksoftirqd/1            11 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/2            13 root      20   0     0    0    0 S    0  0.0   0:03.89 ksoftirqd/2            14 root      RT   0     0    0    0 S    0  0.0   0:00.00 migration/3            16 root      20   0     0    0    0 S    0  0.0   0:00.16 ksoftirqd/3            17 root       0 -20     0    0    0 S    0  0.0   0:00.00 cpuset                 18 root       0 -20     0    0    0 S    0  0.0   0:00.00 khelper                19 root       0 -20     0    0    0 S    0  0.0   0:00.00 netns                  21 root      20   0     0    0    0 S    0  0.0   0:00.01 sync_supers         shafee@shafee-pc:~$   Or is it normal to have 110mb of free memory and is my issue related to something else? File: \boot\bcd Status: 0xc00000e9 windows 8 I am having this error for quite a few months. When the problem occurs, my windows freezes at boot time with black screen. After few reset attempts, sometimes it shows the entitled error. after few attempts, the windows starts but everything become slow. If I again restart, it works well. But at a point windows never starts and I have to reinstall it. I have already reinstalled 3/4 times in the past 2/3 months. I checked for any HDD errors with EASEUS Partition Master Home Edition with surface test, chkdisk at boot time etc for my C drive and F drive but no errors found. Startup repair also fails to solve the problem.  Windows Boot Manager   Windows failed to start. A recent hardware or software change might be the cause.   To fix the problem:  &nbsp;&nbsp;1. Insert your Windows installation disc and restart your computer.  &nbsp;&nbsp;2. Choose your language settings, and then click "Next." &nbsp;&nbsp;3. Click "repair your computer."  If you don't have this disc, contact your system administrator or computer manufacturer for assistance.   &nbsp;&nbsp;File: \Boot\BCD  &nbsp;&nbsp;Status: 0xc00000e9  My laptop's info:  Model: Dell n5110 corei5 OS: Windows 8 PRO 64 bit Anti-virus:  Avast Home edition  Additional info: My Program Files, Program Files (x86) and Users directory is located at F drive and linked with symbolic link (mklink). Also I have changed these basic locations from regedit. I also use eclipse android intelx86 emulator, virtualbox and Genymotion emulator most often. Why is this sentence wrong? "He went to home." Can't cast to to unspecific nested type with generics Writing a compiler in its own language Intuitively, it would seems that a compiler for language Foo cannot itself be written in Foo. More specifically, the first compiler for language Foo cannot be written in Foo, but any subsequent compiler could be written for Foo.  But is this actually true? I have some very vague recollection of reading about a language whose first compiler was written in "itself". Is this possible, and if so how? How do I parse command line arguments in Bash? Using ArcPy to get all database names within server? I am trying to populate a folder with ArcSDE database connection files for all the databases within a server instance.  I need to be able to do this for several of our servers.  Although I know within SQL Server how to get a list of DB names from the sys.databases table, using the arcpy function CreateDatabaseConnection I cannot specify "sys" or "master" to make the connection.  Therefore, I need to know the name of a database currently in the server.  I am not sure how to make the check without hard-coding a name.  import arcpy arcpy.env.overwriteOutput = True  #Input the location where the database connection files will be stored connectionLocation = "F:/FolderName"  #Get the list of servers arcpy.CreateDatabaseConnection_management(out_folder_path= arcpy.env.scratchFolder,out_name= "GIS_USERCONFIG" ,database_platform="SQL_SERVER",\                                           instance = "XXXXXXX" ,account_authentication="DATABASE_AUTH",username="user",password="password",\                                           save_user_pass="SAVE_USERNAME",database= "GIS_USERCONFIG",schema="#",version_type="TRANSACTIONAL",version="dbo.DEFAULT",date="#") sdeConn = arcpy.ArcSDESQLExecute(arcpy.env.scratchFolder + "/GIS_USERCONFIG.sde") serverListSQL = sdeConn.execute("Select name from userservers") serverList = [] for i in range(0,len(serverListSQL)):     serverList.append(serverListSQL[i][0])  #Make a folder for each server instance and build the connection files for all DBs in the server instance for server in serverList:     folder = connectionLocation + "/" + server     if arcpy.Exists(folder):         print server + " folder already created"     else:         try:             arcpy.CreateFolder_management(connectionLocation, server)             print "Created Folder " + server         except:             print "failed to create folder " + server      #     arcpy.CreateDatabaseConnection_management(out_folder_path= arcpy.env.scratchFolder,out_name= server ,database_platform="SQL_SERVER",\                                           instance = server ,account_authentication="OPERATING_SYSTEM_AUTH",\                                           database= "master",schema="#",version_type="TRANSACTIONAL",version="dbo.DEFAULT",date="#")     sdeConn = arcpy.ArcSDESQLExecute(arcpy.env.scratchFolder + "/" + server + ".sde")     dbListSQL = sdeConn.execute("Select name from sys.databases")     dbList = []     for i in range(0,len(serverListSQL)):         dbList.append(dbListSQL[i][0])     for db in dbList:         arcpy.CreateDatabaseConnection_management(out_folder_path= folder ,out_name= db,database_platform="SQL_SERVER",\                                           instance = server ,account_authentication="OPERATING_SYSTEM_AUTH",\                                           database= db,schema="#",version_type="TRANSACTIONAL",version="dbo.DEFAULT",date="#")   Basically my issue is with the 2nd call for the function "CreateDatabaseConnection_management" since it needs a database that exists in the database (and I could not use "master or sys").  If you open this as a tool in arcmap, the input is a drop-down box that populates choices based on the databases in the chosen server instance.  Is there a way to do this in the code? Accessing variables from other functions without using global variables I've heard from a variety of places that global variables are inherently nasty and evil, but when doing some non-object oriented Javascript, I can't see how to avoid them. Say I have a function which generates a number using a complex algorithm using random numbers and stuff, but I need to keep using that particular number in some other function which is a callback or something and so can't be part of the same function.   If the originally generated number is a local variable, it won't be accessible from, there. If the functions were object methods, I could make the number a property but they're not and it seems somewhat overcomplicated to change the whole program structure to do this. Is a global variable really so bad? PHP validation/regex for URL I've been looking for a simple regex for URLs, does anybody have one handy that works well?  I didn't find one with the zend framework validation classes and have seen several implementations. Is there a general formula for finding the primitive of $$e^{ax}\sin(bx)?$$  I've done this manually with $a=9$ and $b=4$ using Euler's formulas. But it takes a bit of time. Is there a pattern here? I have this input:  sdkxyosl 1 safkls 2 asdf--asdfasxy_asd 5 dkd8k  jasd 29 sdi44sw 43 asasd afsdfs 10 rklyasd 4   I need this output:  sdi44sw 43 dkd8k  jasd 29 asasd afsdfs 10 asdf--asdfasxy_asd 5 rklyasd 4 safkls 2 sdkxyosl 1   So i need to sort the lines by the last column.  I don't know how many columns are in one line.  I just can't figure it out, how to do it. I don't have "perl powers". I just have ~average scripting powers with sed, awk, cut, etc..   Does somebody know how to do it? How can I install Ubuntu 13.04 + without USB, CD, DVD or Net? (hard drive only) I have an older i386 Sony Vaio desktop PC where the BIOS only allows boot from floppy, CD or very specific USB device types, none of which seem to recognize USB flash drives for some reason. Floppy is not an option because the drive no longer works and I have no media for it if it did. I've tried assorted CD and DVD drives, the CD drives all give read errors and DVD drives all say "unsupported emulation".  My next possible option that I would like to try, is to install the hard drive into another machine as a second HD and figure out a way to format it and save an Ubuntu installation to run from that HD once it is moved back into the target machine. IS this possible and if so, how would I go about doing so? The currently running machine uses Windows XP. How do I get an operating system onto a new hard drive? Considering the irreducible (by condition) polynomial $f=X^4-2aX^2+b\in\mathbb Q[X]$ and the field extension $K=\mathbb Q(\sqrt{a^2-b})$ of $\mathbb Q$, I want to show the following result:    For $[L:\mathbb Q]=4$ we have $\sqrt b\in K$ where $L$ is the splitting field of $f$.   My thoughts so far: The four roots of $f$ are $\pm\sqrt{a\pm\sqrt{a^2-b}}$. If $L$ is of degree $4$ it must be primitive since $f$ is irreducible, so $L=\mathbb Q\left(\sqrt{a+\sqrt{a^2-b}}\right)$. Then, by multiplying the two roots $\sqrt{a+\sqrt{a^{2}-b}}\cdot\sqrt{a-\sqrt{a^{2}-b}}=\sqrt{b}$ we have that $\sqrt{b}\in L$. Now I want to look at $$\mathbb Q\subset K\subset K(\sqrt b)\subset L$$ and differentiate some cases. The case where $[L:K]=1$ is trivial and the case $[L:K]=4$ can't happen because if we square any root and subtract $a$, we get $\pm\sqrt{a^2-b}\in K$ which means $[L:K]\leq 2$. So let's look at the case where $[L:K]=2$. As I see it, we get two subcases:   For $[L:K(\sqrt b)]=2$ we have $K(\sqrt b)=K$ which finishes the proof. For $[L:K(\sqrt b)]=1$ we have $K(\sqrt b)=L$. This means that $L$ is also the splitting field of $(x^2-b)(x^2-(a^2-b))$. Is this a contradiction? How do I finish this case? How to compress entire drive C in Windows including locked files? What's a big-vocabulary word for someone with a big vocabulary? What's a big-vocabulary word for someone with a big vocabulary?  I'd like to say I'm looking for a "_____".