clean way prepend an element to a numpy array

greg greg at cosc.canterbury.ac.nz
Wed Jul 22 02:51:22 EDT 2009


bdb112 wrote:

> I saw this interest syntax on this site
> x[:0]=0
> 
> I guess that is cute, but could be confusing....(and doesn't work)

It does if you use an array of the appropriate
type on the right hand side:

   a[:0] = array('i', [0])

-- 
Greg



More information about the Python-list mailing list