Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1233840

Browse files
authored
Merge pull request #19415 from dstansby/array-example
DOC: Make TaggedValue in basic_units a sequence
2 parents 3054693 + 3b3cd60 commit 1233840

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

examples/units/basic_units.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ def __str__(self):
154154
def __len__(self):
155155
return len(self.value)
156156

157+
def __getitem__(self, key):
158+
return TaggedValue(self.value[key], self.unit)
159+
157160
def __iter__(self):
158161
# Return a generator expression rather than use `yield`, so that
159162
# TypeError is raised by iter(self) if appropriate when checking for

0 commit comments

Comments
 (0)