Hey guys, I'm using a tutorial geared for a 2.x version of Python and I am currently using Python 3.1-- so it is possible that my confusion has to do with different notations between them. But in any case, here is what I have:
>>> type(Time) <class 'type'> >>> t1 = Time() >>> type(t1) <class '__main__.Time'> where: class Time: def __init__(self, hours = 0, minutes = 0, seconds = 0): self.hours = hours self.minutes = minutes self.seconds = seconds def print_time(t1): print(t.hours, ":", t.minutes, ":", t.seconds) Now the book I am working with has the following example: >>> type(Point) <type 'classobj'> >>> p = Point() >>> type(p) <type 'instance'> My questions are the following: 1) Why is the type for my class Time : >>> type(Time) <class 'type'> when the type for their class Point is: <type 'classobj'> Also, what is the difference between "class" and "classobj" in this case? 2) Why does my t1 object give the following as its type: <class '__main__.Time'> And in their p object example the type is: <type 'instance'>? 3) What is happening such that when I try to call my print_time(t1) function I get the following error: >>> t1 = Time() >>> t1.hours = 3 >>> t1.minutes = 30 >>> t1.seconds = 45 >>> print_time(t1) Traceback (most recent call last): File "<pyshell#77>", line 1, in <module> print_time(t1) NameError: name 'print_time' is not defined Thank you very much. Sincerely, Ben
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor