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.3.3.tar.gz (49.7 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.3.3-py3-none-any.whl (30.4 kB view details)

Uploaded Python 3

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

Uploaded CPython 3.14Windows x86-64

python_box-7.3.3-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.3.3-cp313-cp313-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.13Windows x86-64

python_box-7.3.3-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.3.3-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.3.3-cp312-cp312-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.12Windows x86-64

python_box-7.3.3-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.3.3-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.3.3-cp311-cp311-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.11Windows x86-64

python_box-7.3.3-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.3.3-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.3.3-cp310-cp310-win_amd64.whl (1.3 MB view details)

Uploaded CPython 3.10Windows x86-64

python_box-7.3.3-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.3.3-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.3.3.tar.gz.

File metadata

  • Download URL: python_box-7.3.3.tar.gz
  • Upload date:
  • Size: 49.7 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.3.3.tar.gz
Algorithm Hash digest
SHA256 167ccd4c029ea19744da8edae0ce203bd61f44a1e8ec4032ab2acee2ea1fefbe
MD5 32873c9d41e3f56cf10aa08263c15879
BLAKE2b-256 6a6604534073fc7e3b6efa4a1c991741a6399c403abd7efc1d59ff08e82347ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_box-7.3.3-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.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ed650d3e84068dc24edbcd934fce8270b1dd5648fb122d7d4e03b0a7bbf3f126
MD5 9bad5c235af9dafacbbb878bb69e7eef
BLAKE2b-256 4089322cda67651e3bf6e437eec946aeb58474fb14171857f02e0f7669106296

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_box-7.3.3-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.3.3-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 9f15d696b14360cba92885faae327ac1eba264f8b7d37b798ce8b8f7ca1a2e0b
MD5 dbb49948c85dbddf32c01aa0de7ce43f
BLAKE2b-256 2f034816d3609aac4b6bd0c8f414e4c38e0e2f511a2c7cd83c77ec1a3eb89e2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_box-7.3.3-cp314-cp314-macosx_10_15_universal2.whl
Algorithm Hash digest
SHA256 f9bba8bd30c1970ce565c4f5ab188e673591a726c2a6d6911e09aa8461fb294e
MD5 7f3b0ff8a7652da8cec9ce869e865d8f
BLAKE2b-256 05b3d31251cc52cc6f0976ac3099aebcdacb6d7f6a9721046a7de964b04a8081

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_box-7.3.3-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.3.3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 085e711e9148c681259fb82d3d37ec2488a2565021d532ddc4aeac352fca6051
MD5 17226920ca32790200ee471d9afdb709
BLAKE2b-256 6c26df27f535f1d32b8ceb35d1671fe11e7a9bcf7985e591667c39fb3c0c07ea

See more details on using hashes here.

File details

Details for the file python_box-7.3.3-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.3.3-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 28ebbab478fe3ba64b13ab1010678e94eeebc87d57dc5b34809d71a9525da49d
MD5 e922ad4d8c6f1c607f0a96b0965f57c8
BLAKE2b-256 1167e8b219e2d96da5aa32a77757596e38e976b6bd8778fe4a88eeb69765e472

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_box-7.3.3-cp313-cp313-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 76eb77854ba85921678882ad8b6cde14939e0e81c47d1ee1d75816ab1a20f1c4
MD5 17ccbf7a98922e7c54fc6ae6a0ff497c
BLAKE2b-256 1d8428f2f5fc6c5ece9f55637bc6078da16a2be8fe71c4e0d8a4bc09220047ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_box-7.3.3-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.3.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 96931a145089d8469579f96b91d2cecf09176ac0230c3cbbfa317087f51ed00e
MD5 10a13306318e950df97544cfa6734c52
BLAKE2b-256 bc29f3193fcade14d642b8723794c0273239c4c49b2e0de1d9fffbf781a63fbb

See more details on using hashes here.

File details

Details for the file python_box-7.3.3-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.3.3-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e35b8873ee35e9540507727ce987f31a6a72e631ba8673660cca4e803b06d6c
MD5 dd80e5a03be429d72b7723608a4affa5
BLAKE2b-256 859467357db073652b06af43a81f3a2cc902c4186c50719d3927bb178e42e6aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_box-7.3.3-cp312-cp312-macosx_10_13_universal2.whl
Algorithm Hash digest
SHA256 b596844c3550aa91cd43571650ee5455c32d0953373afa6b61d5063ecd662eb4
MD5 1c5451fa95ef0737a3a05730ddf6a02d
BLAKE2b-256 092cae69ecfe068e7a2e4163981ac15b74adedc4b34cfa7e520ba1bd58e48f96

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_box-7.3.3-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.3.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 192a244219940c2a19c875ca7271da85be327c27505ca925d8814dca92c89982
MD5 cf990b315aa13f3220f2c6a72a7ef23e
BLAKE2b-256 82fb7d4fe04ef4f7c84610bd1cd97780d04e088e17237b1f94da0a9f980d0712

See more details on using hashes here.

File details

Details for the file python_box-7.3.3-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.3.3-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a486ad0c489e64b17170788d28bde4514fb5ed943cc82dc56ed66c13e4d41984
MD5 06aac3a63d5a1fcaa7f255a32dd293b0
BLAKE2b-256 2e47b0b6c0f9933f788308ca5256b152e92a72ebb5bc6fd7b75f860a5305b668

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_box-7.3.3-cp311-cp311-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 9cf119d4f9c15a024fb39f5bda07c0b175eb4dcde7a22194a7f19a44aa85c2ee
MD5 5a0b8d548ff4504d4903052f02ec097a
BLAKE2b-256 78499841eb6a72ba51a21f7de0a2f2ac2404226787ea96d313e8ed0a9382c473

See more details on using hashes here.

File details

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

File metadata

  • Download URL: python_box-7.3.3-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.3.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 217b24a534c21b92b8726af39b605b91f6213a69f843637e9cbfaf77dede1c6a
MD5 45b2599fe6d7cb54b0881483e468cf25
BLAKE2b-256 7ae060d0081088e1763c8f5202059bd38b7872947f7db1a06591790f262c1839

See more details on using hashes here.

File details

Details for the file python_box-7.3.3-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.3.3-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7abab788d419666f99be33388dac84862b5fc775ac337f508f6c28379d7a377f
MD5 1057d53a2daf95dc1ad14e97070ef07c
BLAKE2b-256 0b034b8f3bb156101ca412697559148f793c9dcf229c4f6eb5c141f8ed9e7b2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for python_box-7.3.3-cp310-cp310-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 a0da970bac559fd3de889a38522546e6c0996d5ac4703c9cffd805d01e8b0341
MD5 49fcd9f41fd6d86be32ddf3b51d87de8
BLAKE2b-256 b505b97b6383db2955749306b5a2f699851fd6c1ebf5d1589e175cae272380a9

See more details on using hashes here.

Supported by

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