m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
351 B

6 months ago
  1. from typing import List, TypeVar
  2. T = TypeVar("T")
  3. class Stack(List[T]):
  4. """A small shim over builtin list."""
  5. @property
  6. def top(self) -> T:
  7. """Get top of stack."""
  8. return self[-1]
  9. def push(self, item: T) -> None:
  10. """Push an item on to the stack (append in stack nomenclature)."""
  11. self.append(item)