mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Adding getitem method to _Position.
This commit is contained in:
parent
14e4665301
commit
af54f3512e
1 changed files with 10 additions and 0 deletions
|
|
@ -23,6 +23,16 @@ class _Position(Structure):
|
|||
('y', c_double),
|
||||
('z', c_double)]
|
||||
|
||||
def __getitem__(self, key):
|
||||
if key == 0:
|
||||
return self.x
|
||||
elif key == 1:
|
||||
return self.y
|
||||
elif key == 2:
|
||||
return self.z
|
||||
|
||||
raise ValueError("{} index is invalid for _Position".format(key))
|
||||
|
||||
def __repr__(self):
|
||||
return "({}, {}, {})".format(self.x, self.y, self.z)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue