Inspect python object code with colorful syntax highlighting
Project description
codecolor
Inspect python object code with colorful syntax highlighting!
Free software: Apache Software License 2.0
Documentation: https://codecolor.readthedocs.io.
Codecolor adds color when inspecting source code of python objects. It applies syntax highlighting to object source code.
The primary function of the codecolor module is the printsource function. The printsource(obj, style=”default”) function prints the syntax-highlighted source code for the python object obj.
Codecolor combines the code inspection functionality of inspect.getsource() and syntax highlighting functionality of the pygments package.
Example
How does the pytorch relu function work under the hood? You can easily inspect the source code of the pytorch relu function by using codecolor.printsource(relu) to to print the source code of the relu function with syntax highlighting.
from codecolor import printsource
from torch.nn.functional import relu
printsource(relu)
# prints the source code of the relu function with syntax highlighting
Functions:
printsource(obj, style=”default”)
getsource(obj, style=”default”)
highlight_code(code, style=”default”)
get_all_styles()
To-Do
Add pytest unit tests
Flesh out readme
Example usage
Motivation
Installation
Center logo image
Deploy to pypi
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
History
0.0.1 (2020-09-19)
First release on PyPI.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file codecolor-0.0.2.tar.gz
.
File metadata
- Download URL: codecolor-0.0.2.tar.gz
- Upload date:
- Size: 653.3 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.post20200814 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d50af44a135db210d1f9dff3b55f779d4d1a36607790ca542a64da8ef0b9a0c |
|
MD5 | c0bcc6faee4ccb651d07f6b0bf6ea14a |
|
BLAKE2b-256 | 3b8fefaf7ef305964998e7b4ada2fc0dfb1f7a87fb77ec3a4c6750040e84a113 |
Provenance
File details
Details for the file codecolor-0.0.2-py2.py3-none-any.whl
.
File metadata
- Download URL: codecolor-0.0.2-py2.py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0.post20200814 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77db8357a5a2393691805a9c86ca9c650ba7f78169a07794dafa8c67e7114e3b |
|
MD5 | 4c61610820642c36f3395c24685bb0eb |
|
BLAKE2b-256 | 474c01e9d99d2d2ecbbddaf3eff0d2f1f4fb35aa900b63603a6a6fb2fa826a96 |