![]() |
|
|
|
#1 |
|
if this is too silly a qn pls forgive
I was learning numpy.ndarrays thru the tutorial. 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 p.s(i tried to post to numpy grp but it is not appearing there!) nodrogbrown |
|
|
|
|
#2 |
|
Posts: n/a
|
On Sun, 20 Jan 2008 22:07:31 -0800 (PST), nodrogbrown
<> 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 HTTP://wlfraed.home.netcom.com/ (Bestiaria Support Staff: web-) HTTP://www.bestiaria.com/ Dennis Lee Bieber |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VHDL and EDK: Custom IP core containing an array as a port using EDK | allsey_1987 | Hardware | 0 | 10-27-2009 02:26 PM |
| constants as of array of integers, for loops | octavsly | Hardware | 0 | 04-25-2009 11:53 AM |
| Array Programme | rits | Software | 2 | 03-04-2009 05:18 PM |
| NEWBIE - DVD burn problem - need help | Vic Baron | DVD Video | 6 | 09-29-2005 10:56 PM |