Dennis Lee Bieber
1/21/2008 6:18:00 AM
On Sun, 20 Jan 2008 22:07:31 -0800 (PST), nodrogbrown
<nodrogbrown@gmail.com> declaimed the following in comp.lang.python:
> myarr=numpy.array( [ [10, 20, 30, 40],[1,2,3,4],[5,6,7,8] ] )
> if i want to access the element 3 i can do it by myarr[1, 2]
>
> but then myarr[1][2] will also give the same result..is there any
> reason why two types of indexing is allowed?
> gordon
>
The first is likely a numpy extension (and corresponds to the syntax
many of the classical number crunching languages support: FORTRAN,
Ada...). The second is Python's native syntax (and corresponds to less
focused languages -- such as C; in which a matrix [2D array] is an array
of arrays). You first retrieve the sublist accessed by [1], and then
access the element addressed by [2]
--
Wulfraed Dennis Lee Bieber KD6MOG
wlfraed@ix.netcom.com wulfraed@bestiaria.com
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: web-asst@bestiaria.com)
HTTP://www.bestiaria.com/