Python is getting on my nerves
Posted Tue, 02 May 2006
Add lacking dynamic assignment ability to my "I wish Python had Foo" list.
Python does not appear to have dynamically assignable arrays. Where are we, C? Assembly? When I assign past the end of the array, I mean resize the god damned array. Thanks.
nightfall(~) % python -c "foo = []; foo[3] = 234" Traceback (most recent call last): File "<string>", line 1, in ? IndexError: list assignment index out of rangeThis is completely unacceptable. Sure, I can use list comprehensions to make an N element array that's empty:
foo = [None for x in range(100)] foo[44] = "Hi"That only gets me an array with 100 empty elements. Uh.. Not what I want. If I did this on an array with data in it I didn't want to lose, I'd lose all the data.
Sigh...
I spent many unhappy hours assigning past the ends of arrays in C, and not getting any errors.