Re: need for help

Discussion in 'Python' started by Rob Day, Mar 1, 2013.

  1. Rob Day

    Rob Day Guest

    It looks like you're using single underscores, not double: the methods
    should be __init__ and __str__.

    On 1 March 2013 18:35, leonardo selmi <> wrote:
    > hi guys
    >
    > i typed the following program:
    >
    > class ball:
    > def _init_(self, color, size, direction):
    > self.color = color
    > self.size = size
    > self.direction = direction
    >
    > def _str_(self):
    > msg = 'hi, i am a ' + self.size + ' ' + self.color + 'ball!'
    > return msg
    >
    > myball = ball('red', 'small', 'down')
    > print my ball
    >
    > BUT I GOT THIS ERROR:
    >
    > Traceback (most recent call last):
    > File "/Users/leonardo/Documents/ball2.py", line 11, in <module>
    > myball = ball('red', 'small', 'down')
    > TypeError: this constructor takes no arguments
    >
    > can you kindly tell me what is wrong?
    > thanks a lot!
    > --
    > http://mail.python.org/mailman/listinfo/python-list




    --
    Robert K. Day
     
    Rob Day, Mar 1, 2013
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TN Bella
    Replies:
    1
    Views:
    2,506
    Edward
    Jun 18, 2004
  2. Teep
    Replies:
    2
    Views:
    787
    Larry Marburger
    Jun 21, 2004
  3. John
    Replies:
    1
    Views:
    431
    John C. Bollinger
    Aug 19, 2004
  4. =?Utf-8?B?Q2hyaXM=?=

    Help Help. I really need some help with this

    =?Utf-8?B?Q2hyaXM=?=, Jan 31, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    601
    =?Utf-8?B?SmFzb24gVmVybWlsbGlvbg==?=
    Jan 31, 2007
  5. ElementX
    Replies:
    9
    Views:
    535
    RedGrittyBrick
    Oct 1, 2008
Loading...

Share This Page