Overview
Overview
Magic 8-Ball is a Python package that emulates the classic Magic 8-Ball toy, providing randomized responses to yes-or-no questions. This package is
designed to be both interactive and usable in various applications, allowing developers to integrate a fun, nostalgic feature into their projects.
Features
- 20 traditional Magic 8-Ball responses (positive, neutral, and negative).
- Simple API to ask questions and get a response.
- Custom error handling for invalid inputs.
- Includes comprehensive test coverage.
Installation
pip install wolfsoftware.magic8ball
Usage
Basic Example
Once installed, you can use the Magic 8-Ball package in your Python code.
from wolfsoftware.magic8ball import Magic8Ball
# Create an instance of Magic8Ball
magic_ball = Magic8Ball()
# Ask a yes/no question
response = magic_ball.ask_question("Will it rain tomorrow?")
print("Magic 8-Ball says:", response)
Handling Errors
The ask_question method raises an InvalidQuestionError if the question provided is not a non-empty string. Make sure to validate the input or handle
this exception as shown:
from wolfsoftware.magic8ball import Magic8Ball, InvalidQuestionError
magic_ball = Magic8Ball()
try:
response = magic_ball.ask_question("Will I get a promotion?")
print("Magic 8-Ball says:", response)
except InvalidQuestionError as e:
print("Error:", e)
Release files for wolfsoftware.magic8ball 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wolfsoftware_magic8ball-0.1.0.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wolfsoftware.magic8ball-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.6 kB
Release files / wolfsoftware_magic8ball-0.1.0.tar.gz
| Download URL | wolfsoftware_magic8ball-0.1.0.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cb899c2815c857d1915d5d88374ebfd884b5a0e135362f75114ace9a5384bd37
|
|
BLAKE2b-256 checksum How to use checksums |
e5adf0696a385d067a925e525e34ae72b9b97540a7d88972b1673a8db703f598
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|
Release files / wolfsoftware.magic8ball-0.1.0-py3-none-any.whl
| Download URL | wolfsoftware.magic8ball-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dc94beac4fffd8a66eab0777731cc4933a06ed6b3530715a361614afa7b2a8b5
|
|
BLAKE2b-256 checksum How to use checksums |
370a7b890ed078c6f516bbb3892e2bce7e3efee658a03cd945007ccc4dd3f39d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.13.0
|