A Python library for visualizing and inspecting data structures
Project description
Structoscope
Structoscope is a Python library for visualizing and inspecting any data structure.
Install
The only external dependency is the graphviz
binary, which you can install buy running the following command in the terminal.
brew install graphviz
Now you can install structoscope by running the following command in the terminal.
pip3 install structoscope
Documentation
You can find the documentation for this project here.
Examples
Lists
Structoscope can easily display Python lists:
from structoscope import Scope
s = Scope()
testList = [1,2,3]
s.print(testList)
input() # block the main thread
Multi-dimensional Lists
It can even display multi-dimensional lists:
from structoscope import Scope
s = Scope()
testList = [
[1,2],
[
['a', 'b'],
['c', 'd']
],
'abc'
]
s.print(testList)
input() # block the main thread
Dictionaries
Or it can display dictionaries:
from structoscope import Scope
s = Scope()
testDict = {
'first' : 101,
'second' : 102,
'third' : 103,
}
s.print(testDict)
input() # block the main thread
Trees
It can even display trees:
from structoscope import Scope
class Node:
def __init__(self, val=None, children=[]):
self.val = val
self.children = children
s = Scope(
dataMemberName='val',
childrenMemberName='children'
)
node9 = Node(val='J')
node8 = Node(val='I')
node7 = Node(val='H')
node6 = Node(val='G')
node5 = Node(val='F')
node4 = Node(val='E')
node3 = Node(val='D', children=[node8, node9])
node2 = Node(val='C', children=[node6, node7])
node1 = Node(val='B', children=[node4, node5])
root = Node(val='A', children=[node1, node2, node3])
s.print(root)
input() # block the main thread
What's up with the name?
I think of it as a stethoscope whose purpose is to inspect a struct
. A Struct-o-scope!
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
File details
Details for the file structoscope-0.2.1.tar.gz
.
File metadata
- Download URL: structoscope-0.2.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a137dd235b33ae2ba537c91e42ffa7b08dfe0a43179fb897ffaeb361392d9ae7 |
|
MD5 | 343e107f8e48a9516da1bacdb3bbbe58 |
|
BLAKE2b-256 | 6be2e9dd215b901baf59b5a179299bb18888da38cbdb802d3e555ca98a92f53b |