You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
351 B
Python
17 lines
351 B
Python
![]()
2 months ago
|
from typing import List, TypeVar
|
||
|
|
||
|
T = TypeVar("T")
|
||
|
|
||
|
|
||
|
class Stack(List[T]):
|
||
|
"""A small shim over builtin list."""
|
||
|
|
||
|
@property
|
||
|
def top(self) -> T:
|
||
|
"""Get top of stack."""
|
||
|
return self[-1]
|
||
|
|
||
|
def push(self, item: T) -> None:
|
||
|
"""Push an item on to the stack (append in stack nomenclature)."""
|
||
|
self.append(item)
|