Skip to main content

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, or keep ranks 1 through 4
rank_4_only = list(lottery.find_records(ticket, min_rank=4, max_rank=4))
ranks_1_to_4 = list(lottery.find_records(ticket, min_rank=1, max_rank=4))
print(len(rank_4_only), len(ranks_1_to_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(..., min_rank=..., max_rank=..., strict=...): search matches in history, with inclusive bounds by default and exclusive bounds when strict=True.

See detailed usage guides:

Environment variables

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

  • PACTOLE_CACHE_ROOT
  • USER_AGENT
  • 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.

Release files for pactole 0.4.2

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

Source distribution (sdist)

Source distribution for pactole 0.4.2
File Size Uploaded
pactole-0.4.2.tar.gz 214.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pactole 0.4.2
File Interpreter ABI Platform
pactole-0.4.2-py3-none-any.whl Python 3 none any Details

Total release size: 274.2 kB

Release files / pactole-0.4.2.tar.gz

Download URL pactole-0.4.2.tar.gz
Size 214.8 kB
Tags Source
SHA-256 checksum
How to use checksums
5e1f2473b589d15a1d251846fbb6b7ec2dc9c110677636d1827a7f2e3d6780ee
BLAKE2b-256 checksum
How to use checksums
c03bf85a51f46c6ccc3c17721f67e675a1e4330a2cde037bc4e9507e8c0ed0ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

Release files / pactole-0.4.2-py3-none-any.whl

Download URL pactole-0.4.2-py3-none-any.whl
Size 59.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
30e59bfebbc746141e019bf7c7a2d095b277b880c6a7fccf8521e731b5a9c356
BLAKE2b-256 checksum
How to use checksums
aabcc94101f74827e4d0ef01f63de74dbba802fa27dbec66f06220b23c1bb3ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

Release history Release notifications | RSS feed

This release

0.4.2 This release

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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