Skip to main content

Image

The pythonbible library serves several purposes related to the Christian Bible and Scripture references.

Latest Version
License
Workflows

Code Quality


Supported Python Versions

Documentation

The full documentation for pythonbible can be found at docs.python.bible.

Installation

python3 -m pip install pythonbible

Features

Searching text for scripture references

Given a text, search for scripture references and return any that are found in a list of NormalizedReferences.

For example, given the following text:

import pythonbible as bible

text = "The parable of the lost sheep is told in Matthew 18:12-14 and Luke 15:3-7."
references = bible.get_references(text)

The search functionality should return the following list of scripture references:

[
    NormalizedReference(
        book=<Book.MATTHEW: 40>,
        start_chapter=18,
        start_verse=12,
        end_chapter=18,
        end_verse=14,
        end_book=<Book.MATTHEW: 40>
    ),
    NormalizedReference(
        book=<Book.LUKE: 42>,
        start_chapter=15,
        start_verse=3,
        end_chapter=15,
        end_verse=7,
        end_book=<Book.LUKE: 42>
    )
]

Converting a normalized scripture reference into a list of integer verse ids

Any single verse can be identified by an integer that contains the book, chapter, and verse information. The first 1-2 digits of the integer id represent the book, the next 3 digits represent the chapter, and the last 3 digits represent the verse.

For example, "Genesis 1:1" would be represented as:

1001001

"John 3:16" would be represented as:

43003016

The book of John is the 43rd book of the Bible, "003" represents the 3rd chapter, and "016" represents the sixteenth verse.

Since the book, chapter, and verses are standardized and unlikely to change, this allows us to reference verses in a very efficient way.

Given a normalized scripture reference, which can contain one or more verses, the conversion functionality will convert that normalized scripture reference into a list of verse id integers.

For example, given the following normalized scripture reference for Genesis 1:1-4:

import pythonbible as bible

reference = bible.NormalizedReference(bible.Book.GENESIS, 1, 1, 1, 4, bible.Book.GENESIS)
verse_ids = bible.convert_reference_to_verse_ids(reference)

The conversion functionality would return the following list of verse id integers:

(1001001, 1001002, 1001003, 1001004)

Converting a list of verse id integers into a list of normalized scripture references

The reverse of the above feature, we can take a list of integer verse ids and convert it back into a list of normalized scripture references.

For example, the following list of verse ids represents the references Matthew 18:12-14 and Luke 15:3-7.

import pythonbible as bible

verse_ids = [40018012, 40018013, 40018014, 42015003, 42015004, 42015005, 42015006, 42015007, ]
references = bible.convert_verse_ids_to_references(verse_ids)

The conversion functionality would return the following list of normalized scripture references.

[
    NormalizedReference(
        book=<Book.MATTHEW: 40>,
        start_chapter=18,
        start_verse=12,
        end_chapter=18,
        end_verse=14,
        end_book=<Book.MATTHEW: 40>
    ),
    NormalizedReference(
        book=<Book.LUKE: 42>,
        start_chapter=15,
        start_verse=3,
        end_chapter=15,
        end_verse=7,
        end_book=<Book.LUKE: 42>
    )
]

Converting a list of normalized scripture references into a formatted string scripture reference

Given a list of normalized references, this feature formats them into a human-readable scripture reference string.

It sorts the list so that the references appear in the order they would in the Bible. It also combines verses into ranges when possible.

For example:

import pythonbible as bible

text = "My favorite verses are Philippians 4:8, Isaiah 55:13, and Philippians 4:4-7."
references = bible.get_references(text)
formatted_reference = bible.format_scripture_references(references)

The resulting formatted reference should be:

'Isaiah 55:13;Philippians 4:4-8'

There are a couple of reference formatting features not yet implemented:

  • Smarter pluralization of the book of Psalms (i.e. If just one Psalm is referenced, the singular "Psalm" should be used, but if more than one Psalm is referenced, the plural "Psalms" should be used.)
  • Optional exclusion of the chapter number for books that contain only one chapter (e.g. Some prefer references like Obadiah 1-4 rather than Obadiah 1:1-4, since Obadiah contains only one chapter.)

Formatting Biblical text for print or web display in one or more open-source or public domain versions

This is still a work in progress, but there is some existing functionality related to this.

The related pythonbible-parser library includes a parser to parse OSIS formatted XML files and convert them into a more efficient format for use in Python. The King James and American Standard OSIS files have been converted into python classes and have been included in the pythonbible library and can be currently used to retrieve the text for a single verse:

import pythonbible as bible

verse_text = bible.get_verse_text(1001001, version=bible.Version.KING_JAMES)

The resulting verse_text would be:

'In the beginning God created the heaven and the earth.'

The version argument is optional and currently defaults to AMERICAN_STANDARD. Ideally, that default will be configurable in a future release.

Release files for pythonbible 0.15.5

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

Source distribution (sdist)

Source distribution for pythonbible 0.15.5
File Size Uploaded
pythonbible-0.15.5.tar.gz 28.5 kB Details

Built distribution (wheel)

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

Total release size: 65.2 kB

Release files / pythonbible-0.15.5.tar.gz

Download URL pythonbible-0.15.5.tar.gz
Size 28.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c1e4866b98670e69248621137b927282615dbf820bc55d1731560ab1e06eea96
BLAKE2b-256 checksum
How to use checksums
cfb8fdbd5901214220aac438409a868ea833395b80b513a436351ca4a266df16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.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 / pythonbible-0.15.5-py3-none-any.whl

Download URL pythonbible-0.15.5-py3-none-any.whl
Size 36.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddc74862d7be8db63fd9de05cfcb4c42973239da911e077ae3f79e67852673a5
BLAKE2b-256 checksum
How to use checksums
03ca58debcb7234ccc75c06d84869e2e8e8fa348155aaa87291faff2c026f36e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.9.26 {"installer":{"name":"uv","version":"0.9.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.15.5 This release

2 release files

0.15.3

2 release files

0.15.2

2 release files

0.15.1

2 release files

0.13.1

2 release files

0.13.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

0.9.1

2 release files

0.9

2 release files

0.8

2 release files

0.7.4

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

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