array definition problem?

Tawee Laoitichote astpspd at pea.or.th
Tue Apr 24 02:13:18 EDT 2001


Dear,

What was going on to the following scripts:

python>b=range(4),range(9)[5:],range(14)[10:]
python>a=array(b)
python>print a
[[ 0  1  2  3]
 [ 5  6  7  8]
 [10 11 12 13]]

and

python>a=array(range(4),range(9)[5:],range(14)[10:])
Traceback (most recent call last):
  File "<pyshell#38>", line 1, in ?
    a=array(range(4),range(9)[5:],range(14)[10:])
TypeError: an integer is required
 
but

python>a=array((range(4),range(9)[5:],range(14)[10:]))
python>print a
[[ 0  1  2  3]
 [ 5  6  7  8]
 [10 11 12 13]]

As when we create a tuple, we do not include the whole sequence in the parenthesis.
Or just say that this is the array definition?






More information about the Python-list mailing list