Skip to content

Commit 226968e

Browse files
committed
Make PDAStack subscriptable
For convenience.
1 parent bd5faf3 commit 226968e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

automata/pda/stack.py

+4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ def __iter__(self) -> Iterator[str]:
4949
"""Return an interator for the stack."""
5050
return iter(self.stack)
5151

52+
def __getitem__(self, key):
53+
"""Return the stack element at the given index"""
54+
return self.stack[key]
55+
5256
def __repr__(self) -> str:
5357
"""Return a string representation of the stack."""
5458
return "{}({})".format(self.__class__.__name__, self.stack)

0 commit comments

Comments
 (0)