All Projects → cdgriffith → Box

cdgriffith / Box

Licence: mit
Python dictionaries with advanced dot notation access

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Box

SoftUni-Software-Engineering
SoftUni- Software Engineering
Stars: ✭ 47 (-97.39%)
Mutual labels:  dictionaries, object
Addict
The Python Dict that's better than heroin.
Stars: ✭ 2,141 (+18.68%)
Mutual labels:  dictionaries, addict
Freenom Dns Updater
A tool to update freenom's dns records
Stars: ✭ 117 (-93.51%)
Mutual labels:  pypi
Exabgp
The BGP swiss army knife of networking
Stars: ✭ 1,713 (-5.04%)
Mutual labels:  pypi
Gml
Auto Data Science - Python Library.
Stars: ✭ 125 (-93.07%)
Mutual labels:  pypi
Zatt
Python implementation of the Raft algorithm for distributed consensus
Stars: ✭ 119 (-93.4%)
Mutual labels:  dictionaries
Itunes Iap
Apple iTunes In-app purchase verification tool
Stars: ✭ 126 (-93.02%)
Mutual labels:  pypi
Box Cli Maker
Make Highly Customized Boxes for your CLI
Stars: ✭ 115 (-93.63%)
Mutual labels:  box
Dynamictranslator
Instant translation application for windows in .NET 🎪
Stars: ✭ 131 (-92.74%)
Mutual labels:  dictionaries
Purerpc
Asynchronous pure Python gRPC client and server implementation supporting asyncio, uvloop, curio and trio
Stars: ✭ 125 (-93.07%)
Mutual labels:  pypi
Idapyhelper
IDAPyHelper is a script for the Interactive Disassembler that helps writing IDAPython scripts and plugins.
Stars: ✭ 128 (-92.9%)
Mutual labels:  helper
Obman train
[cvpr19] Demo, training and evaluation code for generating dense hand+object reconstructions from single rgb images
Stars: ✭ 124 (-93.13%)
Mutual labels:  object
On Change
Watch an object or array for changes
Stars: ✭ 1,709 (-5.27%)
Mutual labels:  object
Photoshop Python Api
Python API for Photoshop.
Stars: ✭ 126 (-93.02%)
Mutual labels:  pypi
Best Of Python
🏆 A ranked list of awesome Python open-source libraries and tools. Updated weekly.
Stars: ✭ 1,869 (+3.6%)
Mutual labels:  pypi
Huobi
火币的行情交易的python实现
Stars: ✭ 129 (-92.85%)
Mutual labels:  pypi
Decryptlogin
APIs for loginning some websites by using requests.
Stars: ✭ 1,861 (+3.16%)
Mutual labels:  pypi
Swarmlib
This repository implements several swarm optimization algorithms and visualizes them. Implemented algorithms: Particle Swarm Optimization (PSO), Firefly Algorithm (FA), Cuckoo Search (CS), Ant Colony Optimization (ACO), Artificial Bee Colony (ABC), Grey Wolf Optimizer (GWO) and Whale Optimization Algorithm (WOA)
Stars: ✭ 121 (-93.29%)
Mutual labels:  pypi
Vivify
Vivify is free CSS animation library.
Stars: ✭ 1,651 (-8.48%)
Mutual labels:  helper
Springimpl v2.0
模拟Spring框架,实现IOC,AOP
Stars: ✭ 132 (-92.68%)
Mutual labels:  object

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

pip install --upgrade python-box[all]

Box 5 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 --upgrade python-box[ruamel.yaml,toml,msgpack]

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

Check out more details on installation details.

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

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

Overview

Box is designed to be an easy drop in transparently replacements for dictionaries, thanks to Python's duck typing capabilities, which adds dot notation access. Any sub dictionaries or ones set after initiation will be automatically converted to a Box object. You can always run .to_dict() on it to return the object and all sub objects back into a regular dictionary.

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 lookup 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-2020 Chris Griffith. See LICENSE file.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].