Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: If you want 'between' to be an instance method of the MyTime class, it needs 'self' as well as the 2 arguments 't1' and 't2'. You can then compare the hours, minutes and seconds of self against those of t1 and t2:

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 10:51 PM, kjaku...@gmail.com wrote: So I've now gotten this: class MyTime: def between(self, t1, t2): return (t1.hours, t1.minutes, t1.seconds) = (self.hours, self.minutes, self.seconds) and (self.hours, self.minutes, self.seconds) = (t2.hours,

Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Thursday, July 3, 2014 9:01:09 AM UTC-4, Chris Angelico wrote: And what happens when you run this code? A NameError, I would expect. Do you understand how to define and call methods? ChrisA Altered the code. But yes a nameerror came up class MyTime: def __init__(self,

Re: OOP with MyTime

2014-07-03 Thread MRAB
On 2014-07-03 13:51, kjaku...@gmail.com wrote: On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: If you want 'between' to be an instance method of the MyTime class, it needs 'self' as well as the 2 arguments 't1' and 't2'. You can then compare the hours, minutes and seconds of self

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Thu, Jul 3, 2014 at 11:08 PM, kjaku...@gmail.com wrote: Altered the code. But yes a nameerror came up When that sort of thing happens, you have three basic approaches to solving the problem. 1) Read the traceback, look at the line of code it points to, and see if you can figure out what it

Re: OOP with MyTime

2014-07-03 Thread kjakupak
On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote: On 2014-07-03 13:51, kjaku...@gmail.com wrote: On Wednesday, July 2, 2014 4:02:00 PM UTC-4, MRAB wrote: If you want 'between' to be an instance method of the MyTime class, it needs 'self' as well as the 2 arguments

Re: OOP with MyTime

2014-07-03 Thread Chris Angelico
On Fri, Jul 4, 2014 at 1:21 AM, kjaku...@gmail.com wrote: I keep getting an invalid syntax on the t1 = (9, 59, 59) line, not sure why? t1 = (9, 59, 59) Two points. Firstly, as I said before, posting the entire exception helps us enormously. Secondly, with most computerized parsers, the file

Re: OOP with MyTime

2014-07-03 Thread Mark Lawrence
On 03/07/2014 16:21, kjaku...@gmail.com wrote: On Thursday, July 3, 2014 9:11:49 AM UTC-4, MRAB wrote: I'm pleased to see that you have answers. In return would you please use the mailing list https://mail.python.org/mailman/listinfo/python-list or read and action this

OOP with MyTime

2014-07-02 Thread kjakupak
I'm trying to write a boolean function that takes two Mytime objects, t1 and t2 as arguments, and returns True if the object falls inbetween the two times. This is a question from the How to Think Like a Computer Scientist book, and I need help. What I've gotten so far: class MyTime: def

Re: OOP with MyTime

2014-07-02 Thread Akira Li
kjaku...@gmail.com writes: I'm trying to write a boolean function that takes two Mytime objects, t1 and t2 as arguments, and returns True if the object falls inbetween the two times. This is a question from the How to Think Like a Computer Scientist book, and I need help. What I've

Re: OOP with MyTime

2014-07-02 Thread MRAB
On 2014-07-02 20:20, kjaku...@gmail.com wrote: I'm trying to write a boolean function that takes two Mytime objects, t1 and t2 as arguments, and returns True if the object falls inbetween the two times. This is a question from the How to Think Like a Computer Scientist book, and I need help.