Skip to main content
Latest Version Development Status Build Status Coverage Status Documentation Status

A well tested, cli, python version-agnostic, multi-platform hangman game. It’s built following a TDD workflow and a MVC design pattern. Each component services a sensibly distinct logical purpose. Python Hangman is a version agnostic, tox tested, travis-backed program! Documented and distributed.

Features

Screenshot

Compatibility

Supported Python versions
  • Python 2.6

  • Python 2.7

  • Python 3.3

  • Python 3.4

  • Python 3.5

  • PyPy

Installation

At the command line either via easy_install or pip

$ mkvirtualenv hangman  # optional for venv users
$ pip install python_hangman
$ hangman

Uninstall

$ pip uninstall python_hangman

Goals

2.0.0

MVC pattern. The goal was to explicitly demonstrate an MVC pattern out of the scope of web development.

Idiomatic code. In this overhaul there’s a big emphasis on idiomatic code. The code should be describing its’ own intention with the clarity your grandmother could read.

1.0.0

Learning! This was a Test Driven Development(TDD) exercise.

Also, explored:

  • Tox, test automation

  • Travis CI

  • Python version agnostic programming

  • Setuptools

  • Publishing on pip

  • Coverage via coveralls

  • Documentation with sphinx and ReadTheDocs

  • Cookiecutter development

Design

This game roughly follows the Model-View-Controller(MVC) pattern. In the latest overhaul, these roles have been explicitly named: hangman.model, hangman.view, hangman.controller.

Traditionally in MVC the controller is the focal point. It tells the view what information to collect from the user and what to show. It uses that information to communicate with the model–also, the data persistence later–and determine the next step. This Hangman MVC adheres to these principals

Model

The model is very simply the hangman game instance–hangman.model.Hangman. It’s a class. Every class should have “state” and the methods of that class should manage that state. In this case, the “state” is the current “state of the game”. The public API are for managing that state.

The entirety of the game logic is contained in hangman.model.Hangman. You could technically play the game in the python console by instantiating the class, submitting guesses with the method hangman.model.Hangman.guess and printing the game state.

For example:

>>> from hangman.model import Hangman
>>> game = Hangman(answer='hangman')
>>> game.guess('a')
hangman(status='_A___A_', misses=[], remaining_turns=10)

>>> game.guess('n').guess('z').guess('e')
hangman(status='_AN__AN', misses=['E', 'Z'], remaining_turns=8)

>>> game.status
'_AN__AN'

>>> game.misses
['E', 'Z']

>>> game.remaining_turns
8

View

hangman.view is a collection of stateless functions that represent the presentation layer. When called these functions handles printing the art to the console, and collecting input from the user.

Controller

In this program, the controller is actually the “game_loop”–hangman.controller.game_loop. I still think of it as a controller because the role it plays–communicating I/O from the view with the model-persistence layer.

The controller tells the view later what to print and what data to collect. It uses that information update the state of the game (model) and handle game events.

Call Diagram

Call Diagram

Credits

Tools used in rendering this package:

History

Next Release

  • Stay Posted

2.2.0 (2015-18-05)

  • Fixed max recursion issue with game loop.

  • Updated requirements.

  • Removed gratuitous docs – less is more.

  • 2.2.1 Handle ctrl+d EOF to exit.

  • 2.2.2 Fix broken coverage report.

  • 2.2.3 Fix broken wheel

2.1.0 (2015-18-05)

  • Updated docs, divided and automated in a more reasonable way.

  • renamed the github repo to mirror pypi name.

  • 2.1.1 Fix pypi’s rst render

2.0.0 (2015-12-05)

  • Establishing a changelog.

  • Massive refactoring, explicit MVC structure.

  • Code is even more idiomatic!

  • Created a FlashMessage utility.

  • Removed poorly implemented classes in favor of stateless functions.

  • Add, Remove support for py35, py32.

  • 100% code coverage. (2 untestable, inconsequential lines ignored)

Metadata

Release files for python_hangman 2.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python_hangman 2.2.3
File Size Uploaded Provenance
python_hangman-2.2.3.tar.gz 24.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for python_hangman 2.2.3
File Interpreter ABI Platform
python_hangman-2.2.3-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 39.3 kB

Release files / python_hangman-2.2.3.tar.gz

Download URL python_hangman-2.2.3.tar.gz
Size 24.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c61a15769f6224fdf3089974183d5ef03370b25d224d41f61f50f6975fe343e3
BLAKE2b-256 checksum
How to use checksums
e9a446c566936d8c3d7b1503e0b8eacd0c1b2ca9d20e15a043c1053bae3c924a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python_hangman-2.2.3-py2.py3-none-any.whl

Download URL python_hangman-2.2.3-py2.py3-none-any.whl
Size 14.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3577561c04f80a8fdc50b0c2070072dc343a72613d4f74e3a07a6279ca7a02a6
BLAKE2b-256 checksum
How to use checksums
a83013952e304d9cebb853039643a357a691aa2c250e1f228691317f7b35db77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for python_hangman 2.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page