Jump to content


Photo

Chapter 6 - Class Question


  • Please log in to reply
3 replies to this topic

#1 tazi007

tazi007

    New Member

  • Members
  • Pip
  • 2 posts

Posted 29 May 2011 - 03:47 PM

On page 194. I do the following in IDLE:

>>>class Athlete:
def _init_(self, a_name, a_dob=None, a_times=[]):
self.name=a_name
self.dob=a_dob
self.times=a_times


>>> sarah = Athlete('Sarah Sweeny', '2002-6-17', ['2:58', '2:58', '1:56'])
Traceback (most recent call last):
File "<pyshell#58>", line 1, in <module>
sarah = Athlete('Sarah Sweeny', '2002-6-17', ['2:58', '2:58', '1:56'])
TypeError: object.__new__() takes no parameters

Should I be getting that error response? I can't seem to see what I may have typed wrong.

I am using windows 7 and python 3.2.

#2 tazi007

tazi007

    New Member

  • Members
  • Pip
  • 2 posts

Posted 29 May 2011 - 04:06 PM

I found my issue. Forgot to use double underscores. Works now. Thanks,

#3 nanamiya

nanamiya

    New Member

  • Members
  • Pip
  • 4 posts

Posted 11 October 2013 - 12:44 AM

I found my issue. Forgot to use double underscores. Works now. Thanks,


God!! I have different bug with yours,but your answer saves me.Thank u very much. I think the editor should add this as a notice.

#4 paulbarry

paulbarry

    Advanced Member

  • O'Reilly Author
  • PipPipPipPipPipPipPipPip
  • 307 posts

Posted 13 October 2013 - 05:09 AM

Yes, I've made a note to highlight it in the second edition. Thanks. :-)

--Paul.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users