Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

BuildStatus License

BoxImage

from box import Box

movie_box = Box({ "Robin Hood: Men in Tights": { "imdb stars": 6.7, "length": 104 } })

movie_box.Robin_Hood_Men_in_Tights.imdb_stars
# 6.7

Box will automatically make otherwise inaccessible keys safe to access as an attribute. You can always pass conversion_box=False to Box to disable that behavior. Also, all new dict and lists added to a Box or BoxList object are converted automatically.

There are over a half dozen ways to customize your Box and make it work for you.

Check out the new Box github wiki for more details and examples!

Install

Version Pin Your Box!

If you aren’t in the habit of version pinning your libraries, it will eventually bite you. Box has a list of breaking change between major versions you should always check out before updating.

requirements.txt

python-box[all]~=7.0

As Box adheres to semantic versioning (aka API changes will only occur on between major version), it is best to use Compatible release matching using the ~= clause.

Install from command line

pip install python-box[all]~=7.0 --upgrade

Install with selected dependencies

Box does not install external dependencies such as yaml and toml writers. Instead you can specify which you want, for example, [all] is shorthand for:

pip install python-box[ruamel.yaml,tomli_w,msgpack]~=7.0 --upgrade

But you can also sub out ruamel.yaml for PyYAML.

Check out more details on installation details.

Box 7 is tested on python 3.7+, if you are upgrading from previous versions, please look through any breaking changes and new features.

Optimized Version

Box has introduced Cython optimizations for major platforms by default. Loading large data sets can be up to 10x faster!

If you are not on a x86_64 supported system you will need to do some extra work to install the optimized version. There will be an warning of “WARNING: Cython not installed, could not optimize box” during install. You will need python development files, system compiler, and the python packages Cython and wheel.

Linux Example:

First make sure you have python development files installed (python3-dev or python3-devel in most repos). You will then need Cython and wheel installed and then install (or re-install with –force) python-box.

pip install Cython wheel
pip install python-box[all]~=7.0 --upgrade --force

If you have any issues please open a github issue with the error you are experiencing!

Overview

Box is designed to be a near transparent drop in replacements for dictionaries that add dot notation access and other powerful feature.

There are a lot of types of boxes to customize it for your needs, as well as handy converters!

Keep in mind any sub dictionaries or ones set after initiation will be automatically converted to a Box object, and lists will be converted to BoxList, all other objects stay intact.

Check out the Quick Start for more in depth details.

Box can be instantiated the same ways as dict.

Box({'data': 2, 'count': 5})
Box(data=2, count=5)
Box({'data': 2, 'count': 1}, count=5)
Box([('data', 2), ('count', 5)])

# All will create
# <Box: {'data': 2, 'count': 5}>

Box is a subclass of dict which overrides some base functionality to make sure everything stored in the dict can be accessed as an attribute or key value.

small_box = Box({'data': 2, 'count': 5})
small_box.data == small_box['data'] == getattr(small_box, 'data')

All dicts (and lists) added to a Box will be converted on insertion to a Box (or BoxList), allowing for recursive dot notation access.

Box also includes helper functions to transform it back into a dict, as well as into JSON, YAML, TOML, or msgpack strings or files.

Thanks

A huge thank you to everyone that has given features and feedback over the years to Box! Check out everyone that has contributed.

A big thanks to Python Software Foundation, and PSF-Trademarks Committee, for official approval to use the Python logo on the Box logo!

Also special shout-out to PythonBytes, who featured Box on their podcast.

License

MIT License, Copyright (c) 2017-2023 Chris Griffith. See LICENSE file.

Metadata

Release files for python-box 7.0.0rc1

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-box 7.0.0rc1
File Size Uploaded
python-box-7.0.0rc1.tar.gz 43.8 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for python-box 7.0.0rc1
File
python_box-7.0.0rc1-py3-none-any.whl Python 3 none any Details
python_box-7.0.0rc1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
python_box-7.0.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
python_box-7.0.0rc1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
python_box-7.0.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
python_box-7.0.0rc1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
python_box-7.0.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
python_box-7.0.0rc1-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
python_box-7.0.0rc1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details
python_box-7.0.0rc1-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
python_box-7.0.0rc1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details

Total release size: 22.6 MB

Release files / python-box-7.0.0rc1.tar.gz

Download URL python-box-7.0.0rc1.tar.gz
Size 43.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a224e6c810fbe92b758abe5634fc22c2556d3997b610dfb7682174b6ac1d4faf
BLAKE2b-256 checksum
How to use checksums
34f7e926613b76ffedbe39545f5197a6da2efaebd5083e56e83abf40e60199a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / python_box-7.0.0rc1-py3-none-any.whl

Download URL python_box-7.0.0rc1-py3-none-any.whl
Size 28.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f49d74b249984f25b92ab3aabb30e0c3a87e284afcfd05678ea20a6045740d6b
BLAKE2b-256 checksum
How to use checksums
7d91d8bb02b438b1e71d6090678d52107126a0d6a08296b930b4b6157bfae762
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / python_box-7.0.0rc1-cp311-cp311-win_amd64.whl

Download URL python_box-7.0.0rc1-cp311-cp311-win_amd64.whl
Size 1.0 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
e133823f750335cf0f5819dd876d59897465d74af1a0b75503bb601480e3f88c
BLAKE2b-256 checksum
How to use checksums
39c3c935c9cff27e44264872a4c8f653ec8f5a2311f7e81acd33f28ee5283a39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.1

Release files / python_box-7.0.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-7.0.0rc1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.7 MB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
4f2ba7ae8cc78f28784ccec91c9bbdbe1a3e84da9f3d77755cc6267a60bebc57
BLAKE2b-256 checksum
How to use checksums
672d98e3a0aac30ed2693d39b49db1472411de4b6315130d05bee5eb2b188131
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / python_box-7.0.0rc1-cp310-cp310-win_amd64.whl

Download URL python_box-7.0.0rc1-cp310-cp310-win_amd64.whl
Size 1.0 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
af9fb32d2621fe729fee2be341699d92be7d75ead2554c4c0a46cf0d55a9c42f
BLAKE2b-256 checksum
How to use checksums
fd880b1fbb3e8a941fbc515a965775b6c2a550016126eb27e27c7794187a98cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / python_box-7.0.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-7.0.0rc1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.5 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
08893539c5514bfbb3d3dad2ba1928239f9140cbed093744f3d43240e1e7af21
BLAKE2b-256 checksum
How to use checksums
979ba44a1180593c3f7f0e24501a5d479aeff34c09665c0cf24da20e1525847a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / python_box-7.0.0rc1-cp39-cp39-win_amd64.whl

Download URL python_box-7.0.0rc1-cp39-cp39-win_amd64.whl
Size 1.0 MB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
753fb9f868cc0b4c86c86c754d939bbbd0937f34f3314c4587dda5b0369b6911
BLAKE2b-256 checksum
How to use checksums
c21d58b7446a0d37dd791bd75ca903edc1ac84b7a82757f703ee2730f13c0cc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.13

Release files / python_box-7.0.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-7.0.0rc1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.5 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
5323e800615a3515a6f4e2f6de2594145f2faa66b36fed856fc02f1b0bc56195
BLAKE2b-256 checksum
How to use checksums
8d1efcaedb391f3d632de19fa307aad58889ccaa199e5acfff2d64c41462bf14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / python_box-7.0.0rc1-cp38-cp38-win_amd64.whl

Download URL python_box-7.0.0rc1-cp38-cp38-win_amd64.whl
Size 1.0 MB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
5a28aa7afe5b2f68902ded673ea6504ac01826424f39304a3f5f511eb5d4f5e7
BLAKE2b-256 checksum
How to use checksums
ff9c1bed6b251a079a609e8daff0eef2d8737c807ceb68735fca66919d2556c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.10

Release files / python_box-7.0.0rc1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-7.0.0rc1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.6 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
375063a15c2676021b2fc694d03819724e4490bac98cdcabd51ad6540d45913b
BLAKE2b-256 checksum
How to use checksums
12ef56b85dde33f3d0ed6ae5d808d703b88af5993ce00633f5833ad9db63f7b2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release files / python_box-7.0.0rc1-cp37-cp37m-win_amd64.whl

Download URL python_box-7.0.0rc1-cp37-cp37m-win_amd64.whl
Size 1.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
d4a6fc5437d5743df989c4e833ba4fd156dbd72c1a84078eab34366ac6f25f14
BLAKE2b-256 checksum
How to use checksums
dbe47d9ab40777beec8626d32a2f123bc2b48da9e43c2730d7e839499a78f573
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release files / python_box-7.0.0rc1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-7.0.0rc1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.2 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
a4b7f09b70be110bc7153f439bff35e688b5cf08d36e04cf16a22853462808d2
BLAKE2b-256 checksum
How to use checksums
35ab8a4f2442502a4829d8a6aaafe9c20a82b14be33d2b4451ff33b5f867f8e8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.9

Release history Release notifications | RSS feed

7.4.1

16 release files

7.3.3

16 release files

7.3.2

17 release files

7.3.1

17 release files

7.3.0

17 release files

7.2.0

17 release files

7.1.1

14 release files

7.1.0

10 release files

7.0.1

16 release files

This release

7.0.0rc1 This release

12 release files

6.1.0

17 release files

6.0.1

14 release files

6.0.0

14 release files

5.4.1

2 release files

5.4.0

2 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.1

2 release files

5.1.0

2 release files

5.0.1

2 release files

5.0.0

2 release files

4.2.3

2 release files

4.2.2

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.4

2 release files

4.0.3

2 release files

4.0.2

2 release files

4.0.1

2 release files

3.4.6

2 release files

3.4.5

2 release files

3.4.4

2 release files

3.4.3

2 release files

3.4.2

2 release files

3.4.1

2 release files

3.4.0

2 release files

3.3.0

2 release files

3.2.4

3 release files

3.2.3

3 release files

3.2.2

3 release files

3.2.1

3 release files

3.2.0

3 release files

3.1.1

3 release files

3.1.0

3 release files

3.0.1

3 release files

3.0.0

3 release files

2.2.1

3 release files

2.2.0

3 release files

2.1.0

3 release files

2.0.0

3 release files

1.0.0

3 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