Multidimensional arrays - how?

Jaros³aw Zabie³³o (delete .PL) webmaster at apologetyka.com.pl
Fri May 3 17:06:04 EDT 2002


On Fri, 3 May 2002 10:48:13 -0700, Jeff Shannon <jeff at ccvcorp.com>
wrote:

>In Python, if you want to do this, you have to explicitly create 
>the nested list yourself.  The following will work:
>
>>>> book, chapter, para = 0, 0, 0
>>>> x = [ [ ['para0', 'para1'] ] ]
>>>> x[book][chapter][para]
>'para0'
>>>> x[book][chapter]
>['para0', 'para1']
>>>> 

Yes , but what if I would like to use string keys instead of numbers?
E.g. 

book, chapter, para = 'a', 'b', 'c' ? 

x = [[['para0', 'para1']]] # will not work as I wanted

Nested lists are easer implemented in PHP, I am afraid.
$x['a']['b']['c'] = 'txt' works without any problem.

--
Jarosław Zabiełło (UIN: 6712522)
URL: http://3585753410/~zbiru





More information about the Python-list mailing list