Maccarone lets you delegate sections of your Python program to AI ownership.
Here’s what it looks like in the VS Code extension:

Example
You might write some code like this:
def main(path: str): #> for fn in filenames: #> print(fn, size) #>
Maccarone then fills in the sections you’ve delegated:
>” dir=”auto”>
def main(path: str): #> import os filenames = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))] #> for fn in filenames: #> size = os.path.getsize(os.path.join(path, fn)) #> print(fn, size) #> import argparse parser = argparse.ArgumentParser() parser.add_argument("path", type=str) args = parser.parse_args() main(args.path) #>
Make a change in your code, like adding an extension parameter to main, and Maccarone keeps its sections up to date:
>” dir=”auto”>
def main(path: str, extension: str | None = None): #> … if extension: filenames = [f for f in filenames if f.endswith(extension)] #> … #> … parser.add_argument("--extension", type=str, default=None) args = parser.parse_args() main(args.path, args.extension) #>
Quickstart
Prerequisites
- Python 3.8+
- OpenAI API key with GPT-4 (
export OPENAI_API_KEY)
Easy Mode – VS Code Extension
Easy mode is the free extension from the VS Code marketplace.
Install it in VS Code and you’re done (if you have the prerequisites above).
Other Option – Command Line
If you don’t use VS Code, you can still install Maccarone directly from PyPI:
pip install maccarone
Then run maccarone to generate code and update your source file:
$ maccarone --rewrite examples/file_sizes.py
Usage notes
Running maccarone on a directory
Maccarone can rewrite all files in a directory:
$ maccarone --rewrite --suffix .py examples/
Be careful! You should probably run this only on files in source control, for example.
Related work
- https://github.com/bsilverthorn/vernac
FAQs
It needs my OpenAI API key?
Maccarone prompts GPT-4
>>>
Read More