Python question

  • From: "edward" <personal.edward@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sat, 21 Nov 2009 19:48:18 -0500

hello all 
I am trying to check if one time comes immediately after another.  I wrote a
method called isAfter.  the problem is how do I use it.  meaning to use a
method in python the syntax is x.isAfter but I have two  variables not one.
so I need to x's.
 
edward
code starts
class WhatTime:
 def __init__(self, hour,minute,second):
  self.second=second
  self.minute=minute
  self.hour=hour
 
 def isAfter(self,t1,t2):
  check=t2-t1
  return 1 in check
 def __str__(self):
  return "the time is: "+str(self.hour)+":"+str(self.minute)+"
"+str(self.second)
 
t=WhatTime(10,25,43)
print t
t1=WhatTime(10,12,13)
t2=WhatTime(10,12,14)
isAfter

GIF image

Other related posts: