Coordinate Grid Points
Gabriel Genellina
gagsl-py at yahoo.com.ar
Tue Feb 6 19:08:25 EST 2007
En Tue, 06 Feb 2007 20:35:43 -0300, <Eric.Gabrielson at gmail.com> escribió:
> Anyways heres my error:
> ************************************************************************************************************************
> ***File "C:/Documents and Settings/Eric/Desktop/Python/2d guessing
> game.py", line 11, in <module>***
> *** randp = Point(random.randint(1, 20), random.randint(1,
> 20)) ***
> ***TypeError: default __new__ takes no
> parameters
> ***
> class Point(object):
> def _init_(self, x, y):
> self.x = x
> self.y = y
>
> #generate random coordinate point
> randp = Point(random.randint(1, 20), random.randint(1, 20))
_init_ should be __init__ (two leading and trailing underscores)
That special method is used to initialize your newly constructed Point
instance.
See section 9.3.2 on the Python tutorial:
http://docs.python.org/tut/node11.html#SECTION0011320000000000000000
--
Gabriel Genellina
More information about the Python-list
mailing list