For producing a pseudo-randomized list of playing cards (
Shuffling by taking a random sampling from the available cards and placing them in a position based on a random sampling from available positions in the deck.
$ python -m pip install pcs
$ pipx install pcs
$ uv tool install pcs
Outputs the list of cards to the console and optionally to a file.
With the package installed:
# some_file.py
from pcs import CardShuffle, card_shuffle
import pcs
dealer = CardShuffle() # OR pcs.CardShuffle
dealer.shuffle_cards()
print(dealer.cards_text())
print(card_shuffle())
print(pcs.card_shuffle())
$ python -m pcs
1) Two of Spade
....
52) Queen of Heart
# OR
$ pipx pcs
1) Two of Spade
....
52) Queen of Heart
# OR
$ uvx pcs
1) Two of Spade
....
52) Queen of Heart
$ python -m pcs [-w,--write]
1) Three of Club
....
52) Five of Heart
Decklist written to 'shuffled.decklist.txt'.
# OR
$ pipx pcs [-w,--write]
1) Three of Club
....
52) Five of Heart
Decklist written to 'shuffled.decklist.txt'.
# OR
$ uvx pcs [-w,--write]
1) Three of Club
....
52) Five of Heart
Decklist written to 'shuffled.decklist.txt'.
$ python -m pcs [-g,--gui]
# OR
$ pipx pcs [-g,--gui]
# OR
$ uvx pcs [-g,--gui]
$ python -m pcs [-n, --ndo]
# OR
$ pipx pcs [-n, --ndo]
# OR
$ uvx pcs [-n, --ndo]
$ python card_shuffle.py -h
usage: card_shuffle.py [-h] [-w] [-g] [-n] [-c] [-a]
Producing a pseudo-randomized list of playing cards.
options:
-h, --help show this help message and exit
-w, --write Flag to set for writing output to a text file
-g, --gui Flag to set for displaying output using tkinter
-n, --ndo Flag to set for displaying demo using tkinter. Other options are ignored when set.
-c, --cut Flag to set for cutting the deck after the shuffle at a consecutive pair if found.
-a, --arbitrary Flag to set for cutting the deck after the shuffle at a random spot.
# OR
# uvx pcs -h
