Commit 832f5fc1 authored by Jameson Graef Rollins's avatar Jameson Graef Rollins

fix Struct.__getitem__ to support retrieving nested list elements.

This is not elegant, but it works.
parent 8724a054
......@@ -87,6 +87,11 @@ class Struct(object):
"""
if '.' in key:
k, r = key.split('.', 1)
# FIXME: this is inelegant. better done with regexp?
if len(k.split('[')) > 1:
kl, i = k.split('[')
i = int(i.strip(']'))
return self.__dict__[kl][i][r]
return self.__dict__[k][r]
else:
return self.__dict__[key]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment