Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Automatically gegerate repr to show data structures espelly trees

Project description

Introduction

I opened this project to show datastructures by hacking __repr__ function of Python.

Installation

pip install dsr

Example

from dsr import BinaryTreeNode, TreeNode

print('BinaryTreeNode:')

a = BinaryTreeNode(100)

b = BinaryTreeNode(2)

c = BinaryTreeNode(0, a, b)

d = BinaryTreeNode('a', c, c)

a.right = d

a.left = d



print(d)

print('TreeNode:')

root = TreeNode('tree', [

    TreeNode('types', [TreeNode(str), TreeNode(int)]),

    TreeNode('values', [TreeNode(1), TreeNode(3.1415926), TreeNode(True)]),

    TreeNode('empty'),

    2.718281828,

    'Not TreeNode'

])

print(root)

BinaryTreeNode


                      ('a')                      

                     /     \                     

              (0)                         (0)    

             /   \                       /   \   

    (100)         (2)           (100)         (2)

   /     \                     /     \           

...       ...               ...       ...        

TreeNode


('tree')

 ├── ('types')

 │    ├── (<class 'str'>)

 │    └── (<class 'int'>)

 ├── ('values')

 │    ├── (1)

 │    ├── (3.1415926)

 │    └── (True)

 ├── ('empty')

 ├── 2.718281828

 └── 'Not TreeNode'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dsr, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size dsr-1.0.2-py3-none-any.whl (3.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size dsr-1.0.2.tar.gz (2.6 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page