>>> from Numeric import * #import numeric >>> a = array((1,2,3,4,5)) #create an array >>> a #display the array array([1, 2, 3, 4, 5]) >>> a[2] #index into the array 3 >>> a*2 #new array with twiced values array([ 2, 4, 6, 8, 10]) 
>>> len(a) #get array size 5 >>> a[2:] #elements 2 and up array([3, 4, 5]) >>> a[:2] #all except last 2 array([1, 2, 3]) >>> a[2:] + a[:2] #add first and last array([4, 6, 8]) >>> array((1,2,3)) + array((3,4)) #add arrays of wrong sizes Traceback (innermost last): File "<interactive input>", line 1, in ? ValueError: frames are not aligned 
>>> a #show our starting array array([1, 2, 3, 4, 5]) >>> aa = a[1:3] #slice middle 2 elements >>> aa #show the slice array([2, 3]) >>> aa[1] = 13 #chance value in slice >>> a #show change in original array([ 1, 2, 13, 4, 5]) >>> aaa = array(a) #make copy of array >>> aaa #show copy array([ 1, 2, 13, 4, 5]) >>> aaa[1:4] = 0 #set middle values to 0 >>> aaa #show copy array([1, 0, 0, 0, 5]) >>> a #show original again array([ 1, 2, 13, 4, 5]) 
>>> row1 = (1,2,3) #create a tuple of vals >>> row2 = (3,4,5) #another tuple >>> (row1,row2) #show as a 2D tuple ((1, 2, 3), (3, 4, 5)) >>> b = array((row1, row2)) #create a 2D array >>> b #show the array array([[1, 2, 3], [3, 4, 5]]) >>> array(((1,2),(3,4),(5,6))) #show a new 2D array array([[1, 2], [3, 4], [5, 6]]) 
>>> b #show our array from above array([[1, 2, 3], [3, 4, 5]]) >>> b[0,1] #index a single value 2 >>> b[1,:] #slice second row array([3, 4, 5]) >>> b[1] #slice second row (same as above) array([3, 4, 5]) >>> b[:,2] #slice last column array([3, 5]) >>> b[:,:2] #slice into a 2x2 array array([[1, 2], [3, 4]]) 
>>> c = arange(10) #like range, but makes an array >>> c #show the array array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> c[1:6:2] #slice odd values from 1 to 6 array([1, 3, 5]) >>> c[4::4] #slice every 4th val starting at 4 array([4, 8]) >>> c[8:1:1] #slice 1 to 8, reversed array([8, 7, 6, 5, 4, 3, 2]) 
try: import Numeric as N import pygame.surfarray as surfarray except ImportError: raise ImportError, "Numeric and Surfarray are required." 
32bit  24bit  16bit  8bit(cmap)  

pixel2d  yes  yes  yes  
array2d  yes  yes  yes  yes 
pixel3d  yes  yes  
array3d  yes  yes  yes  yes 
 
 
 
 
 
 
 
 
