Skip to main content

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]~=6.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]~=6.0 --upgrade

Install with selected dependencies

Box is no longer forcing install of external dependencies such as yaml and toml. Instead you can specify which you want, for example, [all] is shorthand for:

pip install python-box[ruamel.yaml,toml,msgpack]~=6.0 --upgrade

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

Check out more details on installation details.

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

Optimized Version

Box 6 is introducing 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]~=6.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-2022 Chris Griffith. See LICENSE file.

Metadata

Release files for python-box 6.0.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 python-box 6.0.2
File Size Uploaded
python-box-6.0.2.tar.gz 40.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for python-box 6.0.2
File
python_box-6.0.2-py3-none-any.whl Python 3 none any Details
python_box-6.0.2-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
python_box-6.0.2-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-6.0.2-cp310-cp310-macosx_10_15_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.15+ x86-64 Details
python_box-6.0.2-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
python_box-6.0.2-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-6.0.2-cp39-cp39-macosx_10_15_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.15+ x86-64 Details
python_box-6.0.2-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
python_box-6.0.2-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-6.0.2-cp38-cp38-macosx_10_14_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.14+ x86-64 Details
python_box-6.0.2-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
python_box-6.0.2-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
python_box-6.0.2-cp37-cp37m-macosx_10_14_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 Details

Total release size: 21.0 MB

Release files / python-box-6.0.2.tar.gz

Download URL python-box-6.0.2.tar.gz
Size 40.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c15f09fa2a8730702115396b490ddc17dde3d4276a4f24eb754e35f102c41347
BLAKE2b-256 checksum
How to use checksums
39c54091b5e7829144e91b5f4ecd4d5a457a63fb6b9be94de714d3fdae0a14ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.10

Release files / python_box-6.0.2-py3-none-any.whl

Download URL python_box-6.0.2-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2565dd56d5e9107e1499ab864f7a4dcd60f63dd5d68215a019308e36c0c98dbc
BLAKE2b-256 checksum
How to use checksums
433bd99e539b4c5dc6c052db02f231bc624dba03ea961e224e1dacb16b1cc3b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.10

Release files / python_box-6.0.2-cp310-cp310-win_amd64.whl

Download URL python_box-6.0.2-cp310-cp310-win_amd64.whl
Size 942.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
8b76359be83ea5d82c3d5ad20614acba522455f4f8c2aecf99847b72acd2db95
BLAKE2b-256 checksum
How to use checksums
4db2514347782a7b5a8a79f3641cba5da187dc3233cb4c7ca845115dfc71de1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release files / python_box-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-6.0.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.3 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
113f4fb6aca9df22689e39f411b4b7cc74d3b284f2fa927666404a58d399f438
BLAKE2b-256 checksum
How to use checksums
31a67f4b90293d208a34a3501c47612b4dc5162236c8cfa16c55c7f7cb726e2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release files / python_box-6.0.2-cp310-cp310-macosx_10_15_x86_64.whl

Download URL python_box-6.0.2-cp310-cp310-macosx_10_15_x86_64.whl
Size 1.1 MB
Tags CPython 3.10 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
41ae4ef7d8336b377b9caa1c1ef5b1efff3aaebe72f580eeb641c01a15288953
BLAKE2b-256 checksum
How to use checksums
e762fadd6fc592d975e9bd664b727841376ef0ed5083c963ffe7b224aa71dc4b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.3

Release files / python_box-6.0.2-cp39-cp39-win_amd64.whl

Download URL python_box-6.0.2-cp39-cp39-win_amd64.whl
Size 941.8 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
99e9f88069855e76cbc4846527d35bc9d1858f2272ab741f29a71c92b72b7b5b
BLAKE2b-256 checksum
How to use checksums
9fa6e948104f3eb54fe106d4a28be9d0d13fcbee3158f5d9c83a44a36eab953e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.10

Release files / python_box-6.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-6.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.3 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
8595d6916eb2ee6c097066886faa5a3fc9392abba8835faa63fd189d1b6ec11b
BLAKE2b-256 checksum
How to use checksums
1f7c407db07bf1ec8950d58ba1a86af21a867e7fbbc39e561efe3312ca84e6a3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release files / python_box-6.0.2-cp39-cp39-macosx_10_15_x86_64.whl

Download URL python_box-6.0.2-cp39-cp39-macosx_10_15_x86_64.whl
Size 1.1 MB
Tags CPython 3.9 macOS 10.15+ x86-64
SHA-256 checksum
How to use checksums
a8f2c20c838d565b92e8733aaa24ea12c0d82f1e415b996e0ef664ac7d02938e
BLAKE2b-256 checksum
How to use checksums
15876a81ab42ad358570f0cfeb3df107858a2d1f20d514b73104f71b8e8d9222
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.9.11

Release files / python_box-6.0.2-cp38-cp38-win_amd64.whl

Download URL python_box-6.0.2-cp38-cp38-win_amd64.whl
Size 944.1 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
b81a5398fdb97de5def918b6c206e3185c173e638d8ded9a3f0e5ef8f3e9da91
BLAKE2b-256 checksum
How to use checksums
2530ac1fa530a6da5334b1821e8bc663211131800426b06be27fff3ab6b43300
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.10

Release files / python_box-6.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-6.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.4 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ce824e4625bb121ef265f7eac54b29ff1c038b4c523bfea606582d8c6185737d
BLAKE2b-256 checksum
How to use checksums
58f387f8b66a086223d5963cc029b63cada0d31493116b17bbe53a256b541610
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release files / python_box-6.0.2-cp38-cp38-macosx_10_14_x86_64.whl

Download URL python_box-6.0.2-cp38-cp38-macosx_10_14_x86_64.whl
Size 1.1 MB
Tags CPython 3.8 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
6cbf14b96afabaeaf6cd8c1da7c05704b0ab84cbd39188826d3fe6b2eed9bc1d
BLAKE2b-256 checksum
How to use checksums
2c32db7daa0770a1167bb5a1dd7005e2e5c9e02637f2625da59dc95dfe35dbcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.8.12

Release files / python_box-6.0.2-cp37-cp37m-win_amd64.whl

Download URL python_box-6.0.2-cp37-cp37m-win_amd64.whl
Size 927.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
449b190d5d8dae6b5ed67a71a0eff57bf9d9654bee2c3e21e54f0489ec0f8fd9
BLAKE2b-256 checksum
How to use checksums
b4ab9bae8e21b8cb4144110ecdb8d3b7809e1dbb0473f8d256812b653eef2ac3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.9

Release files / python_box-6.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL python_box-6.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3a43baf2fdee399c7b3df425e2df163e9551f1d8b40ceb213f9cc0a952effa77
BLAKE2b-256 checksum
How to use checksums
bda014e95a9d67619adaf33fbbb34a3d1bdde67b266c29548bca90edc96ea5aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.2

Release files / python_box-6.0.2-cp37-cp37m-macosx_10_14_x86_64.whl

Download URL python_box-6.0.2-cp37-cp37m-macosx_10_14_x86_64.whl
Size 1.1 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
dbc85880cd01b1272509d660517d0fac94f104f902cc31647d1a27be070d37b3
BLAKE2b-256 checksum
How to use checksums
4e73afd0471244c1c6c59549b8d00388210edd413d011c9e15304b789aa83f2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.12

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

6.1.0

17 release files

This release

6.0.2 This release

14 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