[Tutor] dynamic arrays?

Steven D'Aprano steve at pearwood.info
Mon Sep 27 19:55:25 CEST 2010


On Tue, 28 Sep 2010 01:32:32 am Alex Hall wrote:
> Hi all,
> One thing I have never much liked about Python is its need for
> specifically sized arrays and lack of a dynamic, array-like data
> structure.

Python lists are dynamically sized. If you compare Python to languages 
with fixed-size arrays, like Pascal, you will see the difference: fixed 
arrays are, well, fixed. You declare their size, and then they can 
never change, either increase or decrease. Python lists can do both.

You can increase their size using:

* the append method
* the extend method
* the insert method
* slice assignment

or you can decrease their size using:

* the del statement
* slice assignment



-- 
Steven D'Aprano


More information about the Tutor mailing list