From anonymous, 10 Months ago, written in Python.
Embed
  1. from typing import TypeVar, Sequence
  2.  
  3. _T = TypeVar('_T')
  4.  
  5.  
  6. class NeighborList:
  7.  
  8.     def __init__(self, items: Sequence[_T]) -> None:
  9.         self._items = items
  10.  
  11.     def print_sorted(self) -> None:
  12.         print(sorted(enumerate(self.items), key=lambda e: e[1]))  # <---
  13.  
  14.     @property
  15.     def items(self) -> Sequence[_T]:
  16.         return self._items
  17.  
  18.  
  19. def fun() -> None:
  20.     nl = NeighborList([1, 2, 3])
  21.     print(nl.items[0] - 1)
  22.  
  23. fun()
  24.  

Replies to Untitled rss

Title Name Language When
Re: Untitled anonymous python 10 Months ago.