Skip to main content

A Python library to convert scripts into Jupyter Notebooks with AI-generated comments.

Project description

Py2Notebook AI

Py2Notebook AI is a Python library that transforms Python scripts into Jupyter Notebooks. The tool leverages AI to generate insightful comments for each code block, helping to document and explain the code effectively.

Features

  • Converts Python scripts into Jupyter Notebook format.
  • AI-generated comments for code blocks to improve understanding.
  • Easy-to-use command-line interface.
  • Supports saving and managing OpenAI API keys.
  • Allows overriding the saved API key for specific runs.

Installation

Install Py2Notebook AI via pip:

pip install py2notebook-ai

Usage

1. Configure OpenAI API Key

Before converting scripts, set your OpenAI API key using the following command:

py2notebook-ai config set-key YOUR_OPENAI_API_KEY

This will save your API key locally in a hidden configuration file.

2. Convert Python Script to Notebook

To convert a Python script to a Jupyter Notebook with AI-generated comments:

py2notebook-ai convert your_script.py -o output_notebook.ipynb

If you want to override the saved API key for a specific run:

py2notebook-ai convert your_script.py -o output_notebook.ipynb --api-key YOUR_API_KEY

Example

Input: your_script.py

# your_script.py
def add(a, b):
    return a + b

result = add(5, 3)
print(result)

Output: output_notebook.ipynb

  • A Jupyter Notebook with the code, comments explaining the add function, and the printed result.

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests to enhance the functionality or fix bugs.

License

This project is licensed under the MIT License. See the LICENSE file for details.

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

py2notebook_ai-0.1.3.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py2notebook_ai-0.1.3-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file py2notebook_ai-0.1.3.tar.gz.

File metadata

  • Download URL: py2notebook_ai-0.1.3.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for py2notebook_ai-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ab81df9f7e994db0be08835a7443f0f7abc0a22bd352be0a6a630ae8922ed4a6
MD5 0e1ad06135a6b67defd0d6a9a3728ac7
BLAKE2b-256 d13b023a351655bdc643afea2d130c067f270566ebf6445f9b2f30d83002990b

See more details on using hashes here.

File details

Details for the file py2notebook_ai-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: py2notebook_ai-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for py2notebook_ai-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6d5e162e60a3e7cedc7d7820fc1077e6f0cc037ec941408e094b57c1a4c4b12f
MD5 6e31ec5cc34182403a8efcd1c7bb13d9
BLAKE2b-256 8d97b6f209e16170a4d54b0e9b6ae831a57833b50dae405e2dc84271deb84f3c

See more details on using hashes here.

Supported by

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