diff --git a/examples/units/basic_units.py b/examples/units/basic_units.py index 2a8e94887e95..0e62db1233e6 100644 --- a/examples/units/basic_units.py +++ b/examples/units/basic_units.py @@ -154,6 +154,9 @@ def __str__(self): def __len__(self): return len(self.value) + def __getitem__(self, key): + return TaggedValue(self.value[key], self.unit) + def __iter__(self): # Return a generator expression rather than use `yield`, so that # TypeError is raised by iter(self) if appropriate when checking for