Skip to main content

Inspect python object code with colorful syntax highlighting

Project description

codecolor

https://raw.githubusercontent.com/zkneupper/codecolor/master/docs/_static/code_color_logo.png https://img.shields.io/pypi/v/codecolor.svg https://img.shields.io/travis/zkneupper/codecolor.svg Documentation Status

Inspect python object code with colorful syntax highlighting!

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
https://raw.githubusercontent.com/zkneupper/codecolor/master/docs/_static/codecolor-demo.gif

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


Download files

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

Source Distribution

codecolor-0.0.2.tar.gz (653.3 kB view hashes)

Uploaded Source

Built Distribution

codecolor-0.0.2-py2.py3-none-any.whl (6.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page