dir(re.compile(pattern))    does not return pattern as one of the lists's elements. Namely it returns:  ['__copy__', '__deepcopy__', 'findall', 'finditer', 'match', 'scanner', 'search', 'split', 'sub', 'subn']   According to the manual, it is supposed to contain      the object's attributes' names, the   names of its class's attributes, and   recursively of the attributes of its   class's base classes.   It says also that     The list is not necessarily complete.   Is there a way to get the complete list? I always assumed that dir returns a complete list but apparently it does not...  Also: is there a way to list only attributes? Or only methods?  Edit: this is actually a bug in python -> supposedly it is fixed in the 3.0 branch (and perhaps also in 2.6)
So what I'm looking for here is something like PHP's  function.  This is so I can debug my scripts by seeing what's the state of the object in question.
Variablity in cv.glmnet results I am using cv.glmnet to find predictors. The setup I use is as follows:  lassoResults&lt;-cv.glmnet(x=countDiffs,y=responseDiffs,alpha=1,nfolds=cvfold) bestlambda&lt;-lassoResults$lambda.min  results&lt;-predict(lassoResults,s=bestlambda,type="coefficients")  choicePred&lt;-rownames(results)[which(results !=0)]   To make sure the results are reproducible I set.seed(1). The results are highly variable. I ran the exact same code 100 times to see how variable the results were. In the 98/100 runs had one particular predictor always selected (sometimes just on its own); other predictors were selected (co-efficient was non-zero) usually 50/100 times.  So it tells me that each time the cross-validation is running it's going to probably select a different best lambda, because of the initial randomization of the folds matter. Others have seen this problem () but there isn't a suggested solution.  I am thinking that maybe that one which shows up 98/100 is probably pretty highly correlated to all the others? The results do stabilize if I just run LOOCV ($\text{fold-size} = n$), but I am curious why they are so variable when $\text{nfold} &lt; n$. How can I get a history of running processes Simple homework question about normally distributed variables The question states:      Consider a set of random variables $X_i$, where $i=1,...n$. Each $X_i$ is   normally distributed with mean $0$ and variance $1$, i.e. $X_i$ are $\mathcal N(0,1)$.   What is the mean and the variance of the random variable $Y$, where   $Y=X_1+...+X_n$.   How do I do this? I already have an Apple ID, made at Apple.com. Now, when I want to access the App Store from my iPad, I am told that I have to review my information. On the credit card page, I am not presented with a "None" option, even though I am in the United States.   What can I do to proceed without entering this information? Do neutrinos not couple to the Higgs field? How often do you have to roll a 6-sided die to obtain every number at least once? I've just played a game with my kids that basically boils down to: whoever rolls every number at least once on a 6-sided die wins.  I won, eventually, and the others finished 1-2 turns later. Now I'm wondering: what is the expectation of the length of the game?  I know that the expectation of the number of rolls till you hit a specific number is  $\sum_{n=1}^\infty n\frac{1}{6}(\frac{5}{6})^{n-1}=6$.  However, I have two questions:   How many times to you have to roll a six-sided die until you get every number at least once?  Among four independent trials (i.e. with four players), what is the expectation of the maximum number of rolls needed? [note: it's maximum, not minimum, because at their age, it's more about finishing than about getting there first for my kids]   I can simulate the result, but I wonder how I would go about calculating it analytically.    Here's a Monte Carlo simulation in Matlab  mx=zeros(1000000,1); for i=1:1000000,    %# assume it's never going to take us &gt;100 rolls    r=randi(6,100,1);    %# since R2013a, unique returns the first occurrence    %# for earlier versions, take the minimum of x    %# and subtract it from the total array length    [~,x]=unique(r);     mx(i,1)=max(x); end  %# make sure we haven't violated an assumption assert(numel(x)==6)  %# find the expected value for the coupon collector problem expectationForOneRun = mean(mx)  %# find the expected number of rolls as a maximum of four independent players maxExpectationForFourRuns = mean( max( reshape( mx, 4, []), [], 1) )  expectationForOneRun =    14.7014 (SEM 0.006)  maxExpectationForFourRuns =    21.4815 (SEM 0.01) I have a UK Refugee passport. Do I need a visa to go to France?   I want to go for two days with my husband, but I'm not quite sure if I can go without a visa. Compute $e^{e^z}$, where z is a complex number I am self-studying the MAT 67 linear algebra course and I got stuck at a problem in Chapter 2:     Compute the real and imaginary parts of $e^{e^z}$ for $z$ $\in$ $\Bbb C$.   I tried to expand it using Euler's formula but it seemed endless. Any help? Is "National Socialism" always capitalized? So, I'm writing a paper on the rise of communism in China. At one point I write the following:     "Today, it is well known that communism is responsible for more deaths than even national socialism."   Then, Word corrects it by capitalizing "National Socialism."   Is it always meant to be capitalized? I am simply referencing the ideology, not necessarily the Third Reich. Word didn't bother to correct "communism." I suppose since there was only one instance of Nazism (on a national scale at least) it could be considered a proper noun. Storage order vs Result order This is a spin-off question from .   says this on the subject of storage order (clustered index) and the output order     A lot of people believe that a clustered index guarantees a sort order on output. But that's not what it does; it guarantees a storage order on disk.   See, for example, .   I've read the blog post by Hugo Kornelis and understands that an index doesn't guarantee that the sql server reads the records in a specific order. Yet I have a hard time accepting that I can't assume this for my scenario?  CREATE TABLE [dbo].[SensorValues](   [DeviceId] [int] NOT NULL,   [SensorId] [int] NOT NULL,   [SensorValue] [int] NOT NULL,   [Date] [int] NOT NULL, CONSTRAINT [PK_SensorValues] PRIMARY KEY CLUSTERED  (   [DeviceId] ASC,   [SensorId] ASC,   [Date] DESC ) WITH (     FILLFACTOR=75,     DATA_COMPRESSION = PAGE,     PAD_INDEX = OFF,     STATISTICS_NORECOMPUTE = OFF,     SORT_IN_TEMPDB = OFF,     IGNORE_DUP_KEY = OFF,     ONLINE = OFF,     ALLOW_ROW_LOCKS = ON,     ALLOW_PAGE_LOCKS = ON)   ON [MyPartitioningScheme]([Date])   My original query was this:  SELECT TOP 1 SensorValue   FROM SensorValues   WHERE SensorId = 53     AND DeviceId = 3819     AND Date &lt; 1339225010   ORDER BY Date DESC   But I suggest that I could as well use this one (read below for my explanation):  SELECT TOP 1 SensorValue   FROM SensorValues   WHERE SensorId = 53     AND DeviceId = 3819     AND Date &lt; 1339225010   As you can see, my table rows are small (16bytes) and I've got only one index, a clustered. In my scenario, the table consists of 100.000.000 records at this moment (and this will most likely increase tenfold).  When the database server queries this table it has two ways of finding my rows, either it seeks the primary key and thereby reading and returning my values in desc. order of Date, or it has to do a full table scan. My conclusion is that a full table scan on all those records will be way too slow and the database server will therefore always seek the table via its primary key and thereby returning the values sorted by Date DESC Do continuous linear functions between Banach spaces extend? Does JPA support mapping to sql views? I'm currently using Eclipselink, but I know now days most JPA implementations have been pretty standardized. Is there a native way to map a JPA entity to a view? I am not looking to insert/update, but the question is really how to handle the @Id annotation. Every entity in the JPA world must have an ID field, but many of the views I have created do not conform to this. Is there native support for this in the JPA or do I need to use hacks to get it to work? I've searched a lot and found very little information about doing this. Beamer: PDF presentation viewer to play embedded videos and show elapsed time Can I re-create deleted Gmail accounts? A long time ago, I created a Google mail account. I fell for a trap that was common back then (not sure how it is nowadays) and ended up with two Google accounts—one for Gmail (using the Gmail email address I would like to use) and one for everything else (using an email address at an external mail provider).  Hoping that I could associate my Gmail and my actual Google account, I deleted my Gmail account only to discover that deleted account names cannot be used again. So basically my old Gmail account along with the Google email address I would like to use is gone.  My main Google account got assigned a different Gmail account in the mean time.  Do you know if it is possible to re-use my preferred Gmail address? If possible, I would like to assign it to my main Google account. But I'd also be happy to have it as a second Google account, anything is better than the current situation. Why do I get "unresolved external symbol" errors when using templates? When I write C++ code for a class using templates and split the code between a source (CPP) file and a header (H) file, I get a whole lot of "unresolved external symbol" errors when it comes to linking the final executible, despite the object file being correctly built and included in the linking.  What's happening here, and how can I fix it? What is the best way to convert an array to a hash in Ruby In Ruby, given an array in one of the following forms...  [apple, 1, banana, 2] [[apple, 1], [banana, 2]]   ...what is the best way to convert this into a hash in the form of...  {apple =&gt; 1, banana =&gt; 2} Maximal order of an element in a symmetric group If we let $S_n$ denote the symmetric group on $n$ letters, then any element in $S_n$ can be written as the product of disjoint cycles, and for $k$ disjoint cycles, $\sigma_1,\sigma_2,\ldots,\sigma_k$, we have that $|\sigma_1\sigma_2\ldots\sigma_k|=\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$.  So to find the maximum order of an element in $S_n$, we need to maximize $\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$ given that $\sum_{i=1}^k{|\sigma_i|}=n$. So my question:      How can we determine $|\sigma_1|,|\sigma_2|,\ldots,|\sigma_k|$ such that $\sum_{i=1}^k{|\sigma_i|}=n$ and $\operatorname{lcm}(\sigma_1,\sigma_2,\ldots,\sigma_k)$ is at a maximum?   Example  For $S_{10}$ we have that the maximal order of an element consists of 3 cycles of length 2,3, and 5 (or so I think) resulting in an element order of $\operatorname{lcm}(2,3,5)=30$.  I'm certain that the all of the magnitudes will have to be relatively prime to achieve the greatest lcm, but other than this, I don't know how to proceed. Any thoughts or references? Thanks so much. Best practice of when to load data into a ListBox How can I completely remove a objects (e.g. particle system or groups used in particle systems) in blender using python?  The problem is this: I have a script, with which I create a scene (e.g. adding some normal objects and some group of objects with a particle system). For a research study I would like to repeat that that several times, without restarting blender. So I can create a scene, delete everything, e.g. with a script like this:  import bpy scn = bpy.context.scene for obj in scn.objects:     obj.select = True bpy.ops.object.delete()   If I rerun the script to recreate the scene with objects using particle system, the latter is not shown in the scene anymore (only the placeholders of the particle system). Now I'm not sure where exactly the problem lies, but I guess not everything is immediately deleted, running the script above. Only the startup of blender helps (but that's not what I want) or pushing the purge button. The purge button seems to start the command:  bpy.ops.outliner.orphans_purge()   But I can't get this piece of code to run in the console. It says that "the context is incorrect". Is there a way to purge the unused data by python script? Thanks a lot for any help. How do I make Git use the editor of my choice for commits?