Den 11/06/2014 kl. 14.49 skrev hito koto <
hitoko...@gmail.com>:
> MemoryError , Why? idon't know.
> I try this have Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "<stdin>", line 5, in foo
> MemoryError errors:
>
> I'm change to this code: have the Memory Error,
>
> def foo(x):
> y = []
> while x != []:
> for i in range(len(x)):
> y.append(x[i])
> return y
Your function doesn't modify "x", so "x != []" is always true. You created an endless loop which appends "y" until memory is exhausted. Hence the MemoryError.
These aren't Django-specific questions anymore, so you should head over to a Python mailing list to get further help with basic Python programming.