Skip to main content

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

  1. Install the required tools:
pip install setuptools wheel twine
  1. Create distribution files:
python setup.py sdist bdist_wheel
  1. 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 Distribution

structure_inspector-1.0.1.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

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

structure_inspector-1.0.1-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file structure_inspector-1.0.1.tar.gz.

File metadata

  • Download URL: structure_inspector-1.0.1.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.0

File hashes

Hashes for structure_inspector-1.0.1.tar.gz
Algorithm Hash digest
SHA256 46960831191b9041c1dae992568a11c3cca6a55baf6b0c1ae3f755fee7ab6738
MD5 eda00b01ad5c021376f90027446299c7
BLAKE2b-256 df9b886b41be702b35c4292426339a9df1abf44bd6e6c10b4ca814cfff211a22

See more details on using hashes here.

File details

Details for the file structure_inspector-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for structure_inspector-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4c0ebe378f37a15bad0ddd01ca15baab8299d7038758172338f31a96e1d4bef7
MD5 34cc35f2033ddad5d8c941d343f5d2ba
BLAKE2b-256 6712e618800eaa63447879557a17d15198d88f749d3626a3c595a874742ca41a

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