A Python package to print the structure of complex, nested Python objects.
Project description
Structure Inspector
structure_inspector is a Python package that allows you to print the structure of complex, nested Python objects. It supports dictionaries, lists, tuples, sets, and more. You can also display lengths of lists and strings, handle circular references, and limit recursion depth.
Installation
Install the package using pip:
pip install structure_inspector
Usage
from structure_inspector import StructureInspector
nested_object = {
"name": "Farhan",
"details": {
"age": 35,
"children": [
{"name": "Atta", "age": 10},
{"name": "Dua", "age": 5}
]
},
}
inspector = StructureInspector(max_depth=3, show_lengths=True)
inspector.print_structure(nested_object)
Directory Structure
structure_inspector/
│
├── structure_inspector/
│ ├── __init__.py
│ ├── structure_inspector.py
│
├── README.md
├── LICENSE
├── setup.py
structure_inspector.py
The code above will be placed in structure_inspector/structure_inspector.py.
__init__.py
You can create an empty __init__.py file in the structure_inspector folder so it can be treated as a package.
setup.py
Here’s the content for setup.py, which is required for packaging your module and uploading it to PyPI:
Uploading to PyPI
- Install the required tools:
pip install setuptools wheel twine
- Create distribution files:
python setup.py sdist bdist_wheel
- Upload to pypi
twine upload dist/*
Final Thoughts:
This enhanced version of the program and package adds useful features like circular reference handling, depth limiting, and support for additional types. After packaging it up and uploading it to PyPI, users will be able to install and use it with a simple pip install structure_inspector command.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file structure_inspector-1.0.0-py3-none-any.whl.
File metadata
- Download URL: structure_inspector-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8167c1acf7897049d8b64fef0344d70672af6fe39006d7a2d53e5823dd8c0573
|
|
| MD5 |
1e02e03d59f5583d02d7abcb5014e103
|
|
| BLAKE2b-256 |
0716cd54a5bc7d8f939e93d3ceb6358f2ce1cd4b8deb41a6b4bd2ca39b2120a6
|