From 86e893d7ba4242fc5ca7b72a3fea591c477d2349 Mon Sep 17 00:00:00 2001 From: Olivier Date: Wed, 13 Jan 2021 15:01:16 +0000 Subject: [PATCH] Support integer indexing into lists --- scone/head/variables.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scone/head/variables.py b/scone/head/variables.py index 9e29911..d36cdf6 100644 --- a/scone/head/variables.py +++ b/scone/head/variables.py @@ -113,9 +113,13 @@ class Variables: keys = name.split(".") try: for k in keys: - if not isinstance(current, dict): - raise ValueError(f"non-dictionary encountered when getting {name}") - current = current[k] + if isinstance(current, dict): + current = current[k] + elif isinstance(current, list): + current = current[int(k)] + else: + raise ValueError(f"non-dictionary, non-list encountered when getting {name}") + return current except KeyError: if self._delegate: