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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for structure_inspector-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8167c1acf7897049d8b64fef0344d70672af6fe39006d7a2d53e5823dd8c0573
MD5 1e02e03d59f5583d02d7abcb5014e103
BLAKE2b-256 0716cd54a5bc7d8f939e93d3ceb6358f2ce1cd4b8deb41a6b4bd2ca39b2120a6

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