As you may have noticed, nested objects may not always be the best way to represent data even if that is their logical relationship. As Pekka reminded me lately, the fifth tenet of the
Zen of Python is: Flat is better than nested.
If you want to use names to refer to items of an object, list is not the correct type. You can use a dictionary for that. It will make your test data much more readable.
Dictionaries are very useful, but they cannot be created in the variables table.
That capability is scheduled for 2.9.
For now you have to create the dictionary using keywords or in a
variable file. Collections has a Create Dictionary keyword as well as other keywords for working with lists and dictionaries.
For your example you could:
${object}= Create Dictionary someproperty 42
${outer list}= Create List blah ${object}
Log ${outer list[1]['someproperty']} # note that the key has to be in quotes
this logs 42
IMHO, this is much easier to express in a variable file:
OUTER_LIST = [
u'blah',
{'someproperty': '42'}
]
Another option for more complex testing scenarios is to use your own Python classes that use all or none of the below:
attributes e.g. ${person.phone_number}
indices e.g. ${listing[4]}
keys e.g. ${person['phone_number']}
Regarding your earlier post: if you update the inner list, the change would be reflected anywhere you have a reference to the inner list.
There are two keywords in Collections for copying: Copy List and Copy Dictionary. Note that they only make shallow copies. Thus, this test fails:
${list}= Create List 1 2
${dict 1}= Create Dictionary list ${list}
${dict 2}= Copy Dictionary ${dict 1}
Insert Into List ${dict 1['list']} 0 woah
List Should Not Contain Value ${dict 2['list']} woah