Skip to main content

Advanced Python dictionaries with dot notation access

Project description

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

python -m pip install --upgrade pip
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-2026 Chris Griffith. See LICENSE file.

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

python_box-7.4.1.tar.gz (49.9 kB view details)

Uploaded Source

Built Distributions

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

python_box-7.4.1-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

python_box-7.4.1-cp314-cp314-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.14Windows x86-64

python_box-7.4.1-cp314-cp314-macosx_10_15_universal2.whl (1.9 MB view details)

Uploaded CPython 3.14macOS 10.15+ universal2 (ARM64, x86-64)

python_box-7.4.1-cp313-cp313-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.13Windows x86-64

python_box-7.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

python_box-7.4.1-cp313-cp313-macosx_10_13_universal2.whl (1.8 MB view details)

Uploaded CPython 3.13macOS 10.13+ universal2 (ARM64, x86-64)

python_box-7.4.1-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12Windows x86-64

python_box-7.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

python_box-7.4.1-cp312-cp312-macosx_10_13_universal2.whl (1.8 MB view details)

Uploaded CPython 3.12macOS 10.13+ universal2 (ARM64, x86-64)

python_box-7.4.1-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11Windows x86-64

python_box-7.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

python_box-7.4.1-cp311-cp311-macosx_10_9_universal2.whl (1.9 MB view details)

Uploaded CPython 3.11macOS 10.9+ universal2 (ARM64, x86-64)

python_box-7.4.1-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10Windows x86-64

python_box-7.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (4.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

python_box-7.4.1-cp310-cp310-macosx_10_9_universal2.whl (1.9 MB view details)

Uploaded CPython 3.10macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file python_box-7.4.1.tar.gz.

File metadata

  • Download URL: python_box-7.4.1.tar.gz
  • Upload date:
  • Size: 49.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for python_box-7.4.1.tar.gz
Algorithm Hash digest
SHA256 e412e36c25fca8223560516d53ef6c7993591c3b0ec8bb4ec582bf7defdd79f0
MD5 7564aad7f1ae48384a95a6847569d93e
BLAKE2b-256 0f0f34e7ee0a72f1464b4c7a2e8bafb389f230477256af586bc82bcfad85295a

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-py3-none-any.whl.

File metadata

  • Download URL: python_box-7.4.1-py3-none-any.whl
  • Upload date:
  • Size: 30.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for python_box-7.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3b0d84d003882fb6abe505b1b883b3a5dcbf226b0fe168d24bc5ff75d9826e5
MD5 d2999b9bce9ef66bbdb619e366b21f03
BLAKE2b-256 06a65d3f3abf46b37aa44b1f6788d287c8b4f2319b55013191dddf25b9e6d62c

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: python_box-7.4.1-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for python_box-7.4.1-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 ae8c540a0457f52350211d24690211251912018e1e0c1857f50792729d6f562c
MD5 38018bebab38baae3bc788768d4a11bd
BLAKE2b-256 a65f0e7ea7640ba60ff459ce37e340d816ac5e91b7a9a7c3c161f9dabe622be6

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp314-cp314-macosx_10_15_universal2.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 33c6701faa51fd87f0dcc538873c0fad2b3a1cc3750eab85835cd071cadf1948
MD5 02cbb27f484c342bd5b27adc0544aa1e
BLAKE2b-256 94a2771b5e526bba2214ac2d30e321209a66680c40788616a45cf01005e95204

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: python_box-7.4.1-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for python_box-7.4.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 615da3fafd41572aec1b905832555c0ea08b6fbc27cc917356e257a9a5721af7
MD5 259bad918f156a6558d0c2ad053395c3
BLAKE2b-256 171d7a1e04f37674399e0f3076cfe1fa358f6a51540ae98299a06f2c0424c471

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bb204822c7638bd2dbed5c55d6ab264c6903c37d18dee5c45bdbda58b2e1e17a
MD5 26531756c4d9ca13b4a71889819c6f93
BLAKE2b-256 da7948d38c855f277223caf3aa79518476f95abc07f04386940855b7bd3d95f6

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp313-cp313-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 85db37b43094bf6c4884b931fb149a7850db5ce331f6e191edf98b453e6cf2d6
MD5 152a48fac437ce095fc95f5e4d66be3a
BLAKE2b-256 ece948d1b1eb21efc3f82a31b037b6903c9139018f686d96d251faa4cb0d593a

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: python_box-7.4.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for python_box-7.4.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2ca9a18fd15326bc267e9cc7e0e6e3a0cb78d11507940f43f687adf7e156d882
MD5 eea48abae7617c963b92c09343540f9c
BLAKE2b-256 65f95de3c18415dd6f5286f00e6539c0ae3cceb1c6aaf28d1d5f17b0b568c97f

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b7f977f00e715b030cee6ffef2322ff8ce100ffbf1dbcc4ef91099c75752d5f8
MD5 43d2c9e571bc53c9941333ceb2073aae
BLAKE2b-256 baa3383eb3d658f36c6e531c8cf1e348ccb4b5031231df4aeb7742bb159a3166

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp312-cp312-macosx_10_13_universal2.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 dfb91effff00d9e23486c4f0db3b19e03d602ebb7c9e20fc6a287c704fad2552
MD5 99a2b02d35f3e25a9f21b80b383de432
BLAKE2b-256 4dd9d05f317b38b42253422d8483f5d7dc16d382c99ddc253e426639a0f2f235

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: python_box-7.4.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for python_box-7.4.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 43c62f66d694eb6410f51eb2eb5726f9b466e6f685e5dc90b5cd11f7b3047362
MD5 9d571af51260854e6f1d9ab876540a40
BLAKE2b-256 8ccfb9d1d4550615f69f6f9c72767f026543442739e5c56adf6f844b50d88251

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c66582f41a94d46cb0896d468b0efebf9bc4c3a5634cd15373d871767c2e741d
MD5 7241614d5cc66071179c36f35ebcfe80
BLAKE2b-256 0fbc9382766d388e258363a18a094e251d2624e3c524614c733d1afa989d9770

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp311-cp311-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 3f76dad8be9d57d65a3edc792b952f7afe3991515aa6eba616cf5efb2fbb2e0c
MD5 54ed508fbb482b7d3fd8071f0b48bd1b
BLAKE2b-256 f8a8c8bcd3ff0905ec549273ea3485e6b9f2039f57baab419123fb18f964f829

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: python_box-7.4.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for python_box-7.4.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 526dcc3d82a6957b177313e8704ede431b9add0209b76d716eb232c9a5d283e5
MD5 03249d4727feb47c088730d8d9a306a3
BLAKE2b-256 479494690a217ecb1333a8d796698176456bc03cdf707d903a6bd1aab022a497

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ee7bb8b0c4d1a07f12454a1edc1a936c4bf952adead3eb40c38aee600a2b605b
MD5 1c9ca8338a32e7227b2075e87a0e2769
BLAKE2b-256 5ad0e211693f3ac4f11b553f214fcf2a2687be42052ad6905832258d451003b7

See more details on using hashes here.

File details

Details for the file python_box-7.4.1-cp310-cp310-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for python_box-7.4.1-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 e724eb25bfda0f1dbbe79c8a35ce8877d8ad7afbdd9396757c6f509f0e742f8c
MD5 e02ab0335217e47ec6e340f33512db7d
BLAKE2b-256 f67f0ff288dedf965f504de7a8d9d7353f7b7e57bf18ce9beb328bad49dff026

See more details on using hashes here.

Supported by

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