On Thu, May 19, 2005 at 09:47:50PM +0100, Max Noel wrote: > >On May 19, 2005, at 20:49, William O'Higgins wrote: > >>I am trying to discover the syntax for call on a dictionary of >>lists by >>key and index. >> >>The data structure looks like this: >> >>dol = {'key1':['li1','li2','li3'],'key2':['li1','li2','li3'],\ >>'key3':['li1'li2,'li3','']} >> >>The keys are passed to a function as arguments, and I want the >>value of >>the specified list index. This is what I *thought* it would look >>like: >> >>dol.key(argument)[0] # would return li1 when argument equals key1
> What you are looking for can be achieved like this: > >>>> dol = {'key1':['li1','li2','li3'],'key2':['li1','li2','li3'],\ >... 'key3':['li1', 'li2','li3','']} >>>> dol['key1'][0] >'li1' Ah, of course, it makes sense that an associative array, referenced one array at a time, would use array notation. Ah, crap, I'm speaking Perl again. Make that "it makes sense that a linked list, referenced one list at a time, would use list notation". Thanks. -- yours, William
signature.asc
Description: Digital signature
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor