Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/the0demiurge/datastructurerepr
Automatically gegerate repr to show data structures espelly trees
https://github.com/the0demiurge/datastructurerepr
Last synced: 13 days ago
JSON representation
Automatically gegerate repr to show data structures espelly trees
- Host: GitHub
- URL: https://github.com/the0demiurge/datastructurerepr
- Owner: the0demiurge
- License: mit
- Created: 2018-04-18T03:31:27.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-22T16:10:07.000Z (over 4 years ago)
- Last Synced: 2024-12-16T05:42:06.676Z (18 days ago)
- Language: Python
- Homepage: https://pypi.org/project/dsr/
- Size: 7.81 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Introduction
I opened this project to show datastructures by hacking `__repr__` function of Python.
## Installation
`pip install dsr`
## Example
`from dsr import BinaryTreeNode, TreeNode`
```python
print('BinaryTreeNode:')
a = BinaryTreeNode(100)
b = BinaryTreeNode(2)
c = BinaryTreeNode(0, a, b)
d = BinaryTreeNode('a', c, c)
a.right = d
a.left = dprint(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')
│ ├── ()
│ └── ()
├── ('values')
│ ├── (1)
│ ├── (3.1415926)
│ └── (True)
├── ('empty')
├── 2.718281828
└── 'Not TreeNode'
```