O'Reilly logo

Tkinter GUI Programming by Example by David Love

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The casino package

Within your casino folder, create three files to house these. Name them hand.py, deck.py, and card.py.

In each one, paste in the code from the relevant class.

If you are using an IDE with syntax checking, you may notice a few errors. These are due to the now-missing imports.

In deck.py, ensure you have the following imports:

import randomfrom .card import Card

The random module is needed to shuffle our deck.

The Deck class also relies on having instances of our Card class, so we need to ensure we have access to it. We achieve this by using a relative import.

The relative import is indicated by a single or double dot in front of the module name. In this case, .card tells Python to import from a module named card, which is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required