[Numpy-discussion] array slicing question

Gary Ruben gruben at bigpond.net.au
Mon Apr 4 05:14:09 CDT 2005


Thanks Konrad,
Sorry, my example was too simple. The actual example representing an 
image should have been 2-D and not necessarily square. Therefore I used 
shape instead of len and it seemed messy doing it this way.
Gary

konrad.hinsen at laposte.net wrote:
> On 03.04.2005, at 15:31, Gary Ruben wrote:
> 
>> You might think you could do
>> >>> p=1
>> >>> b = a[p:-p]
>>
>> but if p=0, this fails.
> 
> 
> b = a[p:len(a)-p] works even for p=0.
> 
> Konrad.
> -- 
> ------------------------------------------------------------------------ 
> -------
> Konrad Hinsen
> Laboratoire Leon Brillouin, CEA Saclay,
> 91191 Gif-sur-Yvette Cedex, France
> Tel.: +33-1 69 08 79 25
> Fax: +33-1 69 08 82 61
> E-Mail: khinsen at cea.fr
> ------------------------------------------------------------------------ 
> -------
> 
> 





More information about the Numpy-discussion mailing list