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
addfunction, 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.
Release files for py2notebook-ai 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| py2notebook_ai-0.2.0.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| py2notebook_ai-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:11.3 kB
Release files / py2notebook_ai-0.2.0.tar.gz
| Download URL | py2notebook_ai-0.2.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e86d31ab40751d61ac8e5c9b574f4888370c61f2e3c1a5dca2a3e3942588aae
|
|
BLAKE2b-256 checksum How to use checksums |
87b350645efa825deb9c81a897fa15e73fc3346bf10231d275261b92feef58cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Release files / py2notebook_ai-0.2.0-py3-none-any.whl
| Download URL | py2notebook_ai-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b84373f7ae712daeac4223e3736f2fbf4e10cb50bf50b03a65d0304176a2e34c
|
|
BLAKE2b-256 checksum How to use checksums |
0b21c8d55071e57646acdd14aa83973a31721c5a4b40c1e6f76f4da198d56986
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|