clean way prepend an element to a numpy array

Robert Kern robert.kern at
Wed Jul 22 21:45:41 CEST 2009

On 2009-07-22 01:51, greg wrote:
> 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])

Not when 'a' is a numpy array rather than an array.array.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

More information about the Python-list mailing list