- #1
TylerH
- 729
- 0
I'm trying to convert my __init__ to __new__, but I can't find any docs on how the syntax differs or anything really, that pertains to how this bug could be caused by it. What am I doing wrong here?
It works perfectly like this. When I substitute __new__ for __init__, I get this:
Thanks for your time and help,
Tyler
Code:
import copy;
class grid(list):
def __new__(self, size):
self.size = size;
for i in range(size):
temp = list();
for j in range(size):
temp.append(False);
self.append(temp);
# Other methods that aren't being used and aren't in the trace.
test = grid(2);
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 487, in runfile
execfile(filename, namespace)
File "C:\Python27\Scripts\Grid\grid.py", line 64, in <module>
test = grid(2);
File "C:\Python27\Scripts\Grid\grid.py", line 10, in __new__
self.append(temp);
TypeError: append() takes exactly one argument (0 given)
Thanks for your time and help,
Tyler