Skip to main content

A simple card package which has the types card, face, and suit.

Project description

Card Package

This is a simple card package which has the type card which is a suit, face.

Importing

You can import the card package by:

from card_tb import card
from card_tb import face
from card_tb import suit

Uses

How you can use this package.

Using card

How you can use card.

Instantiate card.Card(suit: Suit, face: Face)

You can use the card using:

_card = card.Card(suit.Suit("KINGS"), face.Face("HEARTS"))

which has the values:

_card.suit.value
_card.face.value

of "KINGS", "HEARTS".

card.Card.card_to_string(_card: card.Card)

A card can be converted to a string representation

card.Card.card_to_string(_card)

has the string representation of "H K".

card.Card.string_to_card(string_representation_of_a_card: str)

The string representation can be converted to a card.

card_string = "H K"

card2 = Card.string_to_card(Card.card_to_string(card))

so card2 == card.Card(suit.Suit("HEARTS"), face.Face("KINGS")).

Using suit

You can use suit:

s = suit.Suit("KINGS")

where you can access the value

s.value == "KINGS"

which has the constants

HEARTS   = "HEARTS"
CLUBS    = "CLUBS"
SPADES   = "SPADES"
DIAMONDS = "DIAMONDS"

SUITS = [HEARTS, CLUBS, SPADES, DIAMONDS]

and

HEARTS_STRING   = "H"
CLUBS_STRING    = "C"
SPADES_STRING   = "S"
DIAMONDS_STRING = "D"

SUITS_STRING = [HEARTS_STRING, CLUBS_STRING, SPADES_STRING, DIAMONDS_STRING]
suit.Suit.suit_to_string(s)

which gives "H".

suit.Suit.string_to_suit("H")

which gives suit("HEARTS").

Using face

You can use face:

f = face.Face("HEARTS")

where you can access the value

f.value == "HEARTS"

which has the constants

ACES   = "ACES"
TWOS   = "TWOS"
THREES = "THREES"
FOURS  = "FOURS"
FIVES  = "FIVES"
SIXES  = "SIXES"
SEVENS = "SEVENS"
EIGHTS = "EIGHTS"
NINES  = "NINES"
TENS   = "TENS"
JACKS  = "JACKS"
QUEENS = "QUEENS"
KINGS  = "KINGS"

FACES = [ACES, TWOS, THREES, FOURS, FIVES, SIXES, SEVENS, EIGHTS, NINES, TENS, JACKS, QUEENS, KINGS]

and

ACES_STRING   = "A"
TWOS_STRING   = "2"
THREES_STRING = "3"
FOURS_STRING  = "4"
FIVES_STRING  = "5"
SIXES_STRING  = "6"
SEVENS_STRING = "7"
EIGHTS_STRING = "8"
NINES_STRING  = "9"
TENS_STRING   = "T"
JACKS_STRING  = "J"
QUEENS_STRING = "Q"
KINGS_STRING  = "K"

FACES_STRING = [ACES_STRING, TWOS_STRING, THREES_STRING, FOURS_STRING, FIVES_STRING, SIXES_STRING, SEVENS_STRING, EIGHTS_STRING, NINES_STRING, TENS_STRING, JACKS_STRING, QUEENS_STRING, KINGS_STRING]
face.Face.face_to_string(f)

which gives "K".

face.Face.string_to_face("K")

which gives face("KINGS").

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

card_tb-0.0.4.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

card_tb-0.0.4-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file card_tb-0.0.4.tar.gz.

File metadata

  • Download URL: card_tb-0.0.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for card_tb-0.0.4.tar.gz
Algorithm Hash digest
SHA256 47de95d8b5d3806cfa4b117664d1ed5e13c8fe1f6b43d66f8aa70b1c3dea14b0
MD5 6d55c880074d84f3698a81be00c76c9b
BLAKE2b-256 ff6db0421b67ca961c5277082aa8a323693339e7567d7ee791a49e7f32d4e330

See more details on using hashes here.

File details

Details for the file card_tb-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: card_tb-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for card_tb-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cbaf0d4be5ea037c213a7d987894a5a27b590e29681b9b4c13a5c47e87653c85
MD5 98610ea5aa6828828a58ba37bf40b055
BLAKE2b-256 121f885107742a1bce319a6a55c9e9f2993ea62f028a1307d58e9e574e8c5f6e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page