Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40286 > unrolled thread
| Started by | Rob Day <robert.day@merton.oxon.org> |
|---|---|
| First post | 2013-03-01 19:41 +0000 |
| Last post | 2013-03-01 19:41 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: need for help Rob Day <robert.day@merton.oxon.org> - 2013-03-01 19:41 +0000
| From | Rob Day <robert.day@merton.oxon.org> |
|---|---|
| Date | 2013-03-01 19:41 +0000 |
| Subject | Re: need for help |
| Message-ID | <mailman.2751.1362166892.2939.python-list@python.org> |
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 <l.selmi@icloud.com> 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
robert.day@merton.oxon.org
Back to top | Article view | comp.lang.python
csiph-web