GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — example-code-2e/05-data-classes/frenchdeck.py at master · FerMatPy/example-code-2e Expand file tree/ Copy pathfrenchdeck.pyMore file actions 17 lines (12 loc) · 487 Bytes / Copy pathfrenchdeck.pyFile metadata and controls17 lines (12 loc) · 487 Bytes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import collections Card = collections.namedtuple('Card', ['rank', 'suit']) class FrenchDeck: ranks = [str(n) for n in range(2, 11)] + list('JQKA') suits = 'spades diamonds clubs hearts'.split() def __init__(self): self._cards = [Card(rank, suit) for suit in self.suits for rank in self.ranks] def __len__(self): return len(self._cards) def __getitem__(self, position): return self._cards[position] |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |