Skip to main content

A library for managing lottery results.

Project description

Pactole

A Python library for managing lottery results.

This is the Python version. A TypeScript version is also available: pactole-js.

Installation

Add pactole to your project:

pip install -U pactole

Or with uv:

uv add -U pactole

Documentation

See the complete documentation index: Documentation. It's also published on ReadTheDocs: pactole.readthedocs.io.

Requirements

Requires Python 3 (version 3.10 or newer).

Usage

import pactole

What you can do with Pactole

With built-in lottery classes (EuroMillions, EuroDreams), you can:

  • Compute last/next draw dates from any date.
  • Build validated tickets from numbers or component ranks.
  • Generate random ticket batches (generate) with optional rank-space partitioning.
  • Query and export historical draws (get_records, count, dump).
  • Search historical results for a ticket and filter by winning rank (find_records).

EuroMillions: plan, generate, and analyze

from datetime import date

from pactole import EuroMillions

lottery = EuroMillions()
today = date(2026, 2, 19)

# 1) Plan around draw days
print(lottery.draw_days.days)
print(lottery.get_last_draw_date(from_date=today))
print(lottery.get_next_draw_date(from_date=today))

# 2) Build a ticket from user input
ticket = lottery.get_combination(numbers=[3, 15, 22, 28, 44], stars=[2, 9])
print(ticket.numbers.values, ticket.stars.values, ticket.rank)

# 3) Generate candidate tickets for the next draw
# partitions spreads picks across slices of the full rank space
suggested = lottery.generate(n=6, partitions=3)
for candidate in suggested:
    print(candidate)

# 4) Inspect history and evaluate your ticket
total_records = lottery.count()
records = list(lottery.get_records())
matches = list(lottery.find_records(ticket))

print(total_records, len(records), len(matches))

# Optional: keep only rank 4 (strict) or better than/equal to rank 4 (non-strict)
exact_rank_4 = list(lottery.find_records(ticket, target_rank=4, strict=True))
at_least_rank_4 = list(lottery.find_records(ticket, target_rank=4, strict=False))
print(len(exact_rank_4), len(at_least_rank_4))

EuroDreams: same workflow, different components

from datetime import date

from pactole import EuroDreams

lottery = EuroDreams()
today = date(2026, 2, 19)

# Draw planning
print(lottery.get_last_draw_date(from_date=today))
print(lottery.get_next_draw_date(from_date=today))

# Ticket creation (numbers + dream)
ticket = lottery.get_combination(numbers=[2, 3, 5, 7, 9, 38], dream=[3])
print(ticket.numbers.values, ticket.dream.values, ticket.rank)

# Ticket suggestions
combinations = lottery.generate(n=3)
print(combinations)

# History lookup for this ticket
records = list(lottery.get_records())
matches = list(lottery.find_records(ticket))
print(len(records), len(matches))

Useful API methods at a glance

  • get_last_draw_date(from_date=...) / get_next_draw_date(from_date=...): draw-day planning.
  • get_combination(...): build a validated game-specific ticket.
  • generate(n=..., partitions=...): create random tickets.
  • count(): total number of cached draw records.
  • get_records(force=False): iterate over structured DrawRecord objects.
  • dump(force=False): export raw dictionary rows (ready for tools like Pandas).
  • find_records(..., target_rank=..., strict=...): search matches in history.

See detailed usage guides:

Environment variables

Built-in lotteries and providers can be configured with environment variables.

  • PACTOLE_CACHE_ROOT
  • FDJ_ARCHIVES_PAGE_URL
  • EUROMILLIONS_PROVIDER_CLASS, EUROMILLIONS_DRAW_DAYS, EUROMILLIONS_DRAW_DAY_REFRESH_TIME, EUROMILLIONS_CACHE_NAME, EUROMILLIONS_ARCHIVES_PAGE
  • EURODREAMS_PROVIDER_CLASS, EURODREAMS_DRAW_DAYS, EURODREAMS_DRAW_DAY_REFRESH_TIME, EURODREAMS_CACHE_NAME, EURODREAMS_ARCHIVES_PAGE

See the full reference with defaults and behavior: Environment variables.

Changes

For the changelog, see CHANGELOG.md.

License

MIT License - See LICENSE file for details.

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

pactole-0.4.0.tar.gz (213.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pactole-0.4.0-py3-none-any.whl (58.5 kB view details)

Uploaded Python 3

File details

Details for the file pactole-0.4.0.tar.gz.

File metadata

  • Download URL: pactole-0.4.0.tar.gz
  • Upload date:
  • Size: 213.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pactole-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d25612ec7a69894d3e6ca71014318275ead2e8890347cf0b24551c1a1a7b8f8c
MD5 938db0f7c0401a744fab2d80d9db684b
BLAKE2b-256 90ed6b846b32da2f21c3791435babbd6fcf9f85c774b9c830e572446fd33da63

See more details on using hashes here.

File details

Details for the file pactole-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pactole-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 58.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pactole-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1ed8061386bf780b065142f88af758dc2b8027030255e75320a2beec3addbed
MD5 71ef0617a52a3269b8355fab846dffb4
BLAKE2b-256 aeaa06373d178614adeff14c73e8cf876e1eeb9fbd8bf6ae8ded0090f6ebe98d

See more details on using hashes here.

Supported by

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