I have two sets which returns a specific value. I would like to carry out an operation on set apple. if length of this this set is greater than 0, i woulf like to calculate the elapsed time. If the time passed more than 10 sec, i would like to reset time to zero. Any suggestion to deal this?  apple = set([1,5,9,13]) orange = set([2,4,6,8,10])  def fruit(apple,orange):      if len(apple)&gt;0:         time_now = time.time()     if time_now &gt;10:         apple.clear()         time_now == 0 return apple, orange
13304
I would like to know how to put a time delay in a Python script.
31018
Is "empty set" an element of a set? For example:  is this FALSE?:  0 ∈ {1,2,3}
113449
As documented in the blog post , on x86 systems, Java's System.nanoTime() returns the time value using a  specific counter. Now consider the following case I use to measure time of a call:  long time1= System.nanoTime(); foo(); long time2 = System.nanoTime(); long timeSpent = time2-time1;   Now in a multi-core system, it could be that after measuring time1, the thread is scheduled to a different processor whose counter is less than that of the previous CPU. Thus we could get a value in time2 which is less than time1. Thus we would get a negative value in timeSpent.  Considering this case, isn't it that System.nanotime is pretty much useless for now?  I know that changing the system time doesn't affect nanotime. That is not the problem I describe above. The problem is that each CPU will keep a different counter since it was turned on. This counter can be lower on the second CPU compared to the first CPU. Since the thread can be scheduled by the OS to the second CPU after getting time1, the value of timeSpent may be incorrect and even negative.
123574
I assume this is correct to any size set, not 2015 in particular... it's obviously true for 2. I know from pen and paper it's true for 3, and 4....  I understand that I should look at the reminders, and build pigeonholes from them.  If one of the numbers has a 0 reminder obviously the entire set is divisible, so the possible reminders go from 1 to (n-1). i have n numbers hence one of the reminders repeats. the sums of the reminders go from 1 to n*(n-1)....  And that's it...  Any and all help would be appreciated.    Of course I mean non empty set...
82341
example:  a_list = [1, 2, 3] a_list.len() # doesn't work len(a_list) # works   Python being (very) object oriented, I don't understand why the 'len' function isn't inherited by the object.  Plus I keep trying the wrong solution since it appears as the logical one to me
101325
Can a set be neither open nor closed? An example would do. I cant think of any.   Thanks in advance!
1661
I find it funny that Java (or the java.util library) does not have a built-in function to calculate difference in dates. I want to subtract one date from another to get the elapsed time between them. What is the best way to do this?   I know the simple way is to take the difference of the time in milliseconds and then convert that into days. However, I wanted to know if this works in all cases (with daylight saving, etc.).
67323
Why is a signed integer used to represent timestamps? There is a clearly defined start at 1970 that's represented as 0, so why would we need numbers before that? Are negative timestamps used anywhere?
41131
Sorry but I don't think I can know, since it's a definition. Please tell me. I don't think that $0=\emptyset\,$ since I distinguish between empty set and the value $0$. Do all sets, even the empty set, have infitinite emptiness e.g. do all sets including the empty set contain infinitely many empty sets?
57658
I'm thinking of modulo, but really don't know how to start? A hint would be sufficient.     Thanks, Chan
16336
Given the following code (that doesn't work):  while True:     #snip: print out current state     while True:         ok = get_input("Is this ok? (y/n)")         if ok.lower() == "y": break 2 #this doesn't work :(         if ok.lower() == "n": break     #do more processing with menus and stuff   Is there a way to make this work? Or do I have do one check to break out of the input loop, then another, more limited, check in the outside loop to break out all together if the user is satisfied?
78279
I'm sure there's a simpler way of doing this that's just not occurring to me.  I'm calling a bunch of methods that return a list.  The list may be empty.  If the list is non-empty, I want to return the first item; otherwise, I want to return None.  This code works:  my_list = get_list() if len(my_list) &gt; 0: return my_list[0] return None   It seems to me that there should be a simple one-line idiom for doing this, but for the life of me I can't think of it.  Is there?  Edit:  The reason that I'm looking for a one-line expression here is not that I like incredibly terse code, but because I'm having to write a lot of code like this:  x = get_first_list() if x:     # do something with x[0]     # inevitably forget the [0] part, and have a bug to fix y = get_second_list() if y:     # do something with y[0]     # inevitably forget the [0] part AGAIN, and have another bug to fix   What I'd like to be doing can certainly be accomplished with a function (and probably will be):  def first_item(list_or_none):     if list_or_none: return list_or_none[0]  x = first_item(get_first_list()) if x:     # do something with x y = first_item(get_second_list()) if y:     # do something with y   I posted the question because I'm frequently surprised by what simple expressions in Python can do, and I thought that writing a function was a silly thing to do if there was a simple expression could do the trick.  But seeing these answers, it seems like a function is the simple solution.
12628
Is there a benefit to using one over the other? In Python 2, they both seem to return the same results:  &gt;&gt;&gt; 6/3 2 &gt;&gt;&gt; 6//3 2
46272
Suppose I have a non-empty set $A$.     How do I choose an element $x\in A$?   More precisely, I believe I would like to find a formula $P(x,y)$ of ZF such that for every non-empty set $y$ there is exactly one $x\in y$ such that $P(x,y)$ is true.  I have thought about this for a while without success and I am beginning to doubt such a formula is even possible. But in mathematical proofs it is quite common to "choose a fixed element" from a non-empty set. So how exactly do we achieve such a thing? Am I missing something?  Thank you in advance.
92403
I know that you can use daysBetween() for two Date objects, but what would I use to calculate the elapse time in seconds between two DateTime objects?
77040
When I try to use the "set inverse" operator in python there comes an error that it missed a context called "constraint". But I did it exactly like in the Info Panel.  bpy.ops.constraint.childof_set_inverse(constraint="Child Of", owner='BONE')   The Name of the constraint is correct and the also the owner
27536
I wish to calculate the time it took for an API to return a value. The time taken for such an action is in the space of nanoseconds. As the API is a C++ class/function, I am using the timer.h to calculate the same:   #include &lt;ctime&gt;   #include &lt;iostream&gt;    using namespace std;    int main(int argc, char** argv) {        clock_t start;       double diff;       start = clock();       diff = ( std::clock() - start ) / (double)CLOCKS_PER_SEC;       cout&lt;&lt;&quot;printf: &quot;&lt;&lt; diff &lt;&lt;'\n';        return 0;   }  The above code gives the time in seconds. How do I get the same in nano seconds and with more precision?