How to find two close events (that have a datetime component) in python -


I have an object that represents an event, and I have several objects.

I

  join_events = [[event_a.time, event_a] The best way I can get this to do is:  

details, event_b.time, event_b.description] event_a in events_a in events_b in event_b if abs (event_a.time - event_b.time) & lt;

But I expected that there was a better way to do this. Text "itemproc =" text ">

Beauty is in the eye of the beholder, but hopefully it is less unlucky for you :)

  import itertools import from datetime Product Delta = Datetime.timedelta (hours = 1) join_events = [[a.time, a.description, b.time, b.description] for A, b in the product (events_a, events_b) if abs (a.time -b.time) ) & Lt; delta]  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -