🌐
Reddit
reddit.com › r/python › python code generation tools
r/Python on Reddit: Python Code Generation Tools
March 9, 2019 -

What do you guys use to generate Python code? I saw that a lot of people just use Jinja2 with some templates, which looks simple and powerful. You still have to generate the environments and write the templates. Now I'm looking around whether someone already did the work of generalizing that step (thinking about fields in classes, inheritance, constructors etc. and how to map that data to the environment) or whether I have to do it myself.

TLDR: Are there simple but powerful Python code generation "frameworks"?

EDIT:

  • I found pymultigen. Seems like it helps with creating code in multiple files.

  • Looks like pyecoregen is a specialized multi-file code generator based on pymultigen.

Top answer
1 of 3
2
I'd probably use metaclasses if I had the kind of problem where code generation could actually help. The last time I saw a project using code generation where I thought that it ought have to used metaclasses was a tool to generate python code from swagger descriptions. Django's ORM is a good example where metaclasses were used to good effect (there are very few of those). In general I'm extremely suspicious of anybody who claims to have the kind of problem that requires either metaclasses or code generation would help though. It is suitable only for problems that are very, very, very abstract (e.g. like an ORM or REST API interaction framework). In 90% of cases I've seen the person attempting to use it vastly overgeneralized the problem that they actually had in an attempt to prepare for future problems never arose. In the process of doing that they then created a code clusterfuck that was hellishly hard to understand and debug (and in some cases I was left to clean up the mess). It wasn't simple and it can't, intrinsically, ever be simple (there is some language theory behind this). I could be convinced otherwise by describing your problem, but right now I'm 80% convinced that what you have described is an XY problem and that you're attempting to do this because you overgeneralized your problem. If you describe the actual problem you're solving it might help.
2 of 3
2
If you're looking for some codegen support stuffs in python, I'd give you some info Python std module ast AST to python source code emitter, unparse. https://github.com/python/cpython/blob/master/Tools/parser/unparse.py AST based scoping analyzer, https://github.com/thautwarm/scoping-resolver
🌐
GitHub
github.com › modm-io › lbuild
GitHub - modm-io/lbuild: lbuild: a generic, modular code generator in Python 3 · GitHub
lbuild: a generic, modular code generator in Python 3 - modm-io/lbuild
Starred by 43 users
Forked by 11 users
Languages   Python
Discussions

code generation - Python generating Python - Stack Overflow
I've done the same thing (well, generating java from python in this case) using str.format. - while it feels a bit wrong on some level, it's a lot easier to see whats going on than using an AST for instance. 2015-10-21T09:55:55.453Z+00:00 ... I recently developed a command-line tool for Jinja2 especially the code generation in mind. github... More on stackoverflow.com
🌐 stackoverflow.com
templates - Best Python templating library to facilitate code generation - Stack Overflow
I have made a command-line tool based on Jinja2 to do code generation. github.com/kblomqvist/yasha 2016-03-19T10:01:36.643Z+00:00 More on stackoverflow.com
🌐 stackoverflow.com
Python Code Generation Tools
I'd probably use metaclasses if I had the kind of problem where code generation could actually help. The last time I saw a project using code generation where I thought that it ought have to used metaclasses was a tool to generate python code from swagger descriptions. Django's ORM is a good example where metaclasses were used to good effect (there are very few of those). In general I'm extremely suspicious of anybody who claims to have the kind of problem that requires either metaclasses or code generation would help though. It is suitable only for problems that are very, very, very abstract (e.g. like an ORM or REST API interaction framework). In 90% of cases I've seen the person attempting to use it vastly overgeneralized the problem that they actually had in an attempt to prepare for future problems never arose. In the process of doing that they then created a code clusterfuck that was hellishly hard to understand and debug (and in some cases I was left to clean up the mess). It wasn't simple and it can't, intrinsically, ever be simple (there is some language theory behind this). I could be convinced otherwise by describing your problem, but right now I'm 80% convinced that what you have described is an XY problem and that you're attempting to do this because you overgeneralized your problem. If you describe the actual problem you're solving it might help. More on reddit.com
🌐 r/Python
18
8
March 9, 2019
Code Generation
I don't tend to use code generators at all. Go does have some boilerplate but in terms of things like defining a simple data model, it doesn't have any more code than any equivalent language. I find most code generators fairly irritating most of the time. Better than a framework, which tends to turn into a straightjacket in a hurry, but still frustrating. I've personally never found Go to be particularly burdensome to write, maybe that's just because I come from static OOP languages like Java and C# which tend to have mountains of boilerplate. More on reddit.com
🌐 r/golang
17
66
April 10, 2021
🌐
GitHub
github.com › visualpython › visualpython
GitHub - visualpython/visualpython: GUI-based Python code generator for data science, extension to Jupyter Lab, Jupyter Notebook and Google Colab. · GitHub
GUI-based Python code generator for data science, extension to Jupyter Lab, Jupyter Notebook and Google Colab. - visualpython/visualpython
Starred by 918 users
Forked by 118 users
Languages   JavaScript 87.3% | HTML 5.5% | CSS 5.3% | Python 1.0% | Jupyter Notebook 0.3% | Batchfile 0.3% | Shell 0.3%
🌐
GitHub
github.com › yuchdev › code_generator
GitHub - yuchdev/code_generator: Simple and straightforward code generator for creating program code. At the moment offers support for C++, Java and HTML5 for generating reports.
Simple and straightforward code generator for creating C++ code. It also could be used for generating code in any programming language. Written in Python, works both with Python 2 and 3
Starred by 100 users
Forked by 21 users
Languages   Python 97.9% | C++ 1.9% | C 0.2% | Python 97.9% | C++ 1.9% | C 0.2%
🌐
GitHub
github.com › topics › code-generator
code-generator · GitHub Topics · GitHub
docker cli aws code-generator terraform python3 aws-cli code-generation terraform-import aws-api ... Code generation tool, creates python / C programs that parse command line arguments.
🌐
Qodo
qodo.ai › blog › news & updates › top 7 python code generator tools in 2025
Top 7 Python Code Generator Tools in 2025 - Qodo
May 16, 2025 - Python developers can use GitHub Copilot to generate boilerplate code for Python applications, and beginners can learn about various language constructs using the interactive Copilot interface, as well as build robust backend applications using ...
🌐
GitHub
github.com › topics › generator-python
generator-python · GitHub Topics · GitHub
osint google-dorks generator-python dorker dorking dorks osint-python python-osint dorks-dumper dorking-tool ... Here is a GAN model which is trained on the repositories of Github python projects to generate python code.
Find elsewhere
🌐
GitHub
github.com › codespin-ai › codespin
GitHub - codespin-ai/codespin: CodeSpin.AI Code Generation Tools
Ready to try? The following command generates code for a Hello World app and displays it: codespin gen --prompt 'Make a python program (in main.py) that prints Hello, World!'
Starred by 60 users
Forked by 5 users
Languages   TypeScript 87.0% | JavaScript 13.0% | TypeScript 87.0% | JavaScript 13.0%
🌐
Fabi
fabi.ai › blog › best-ai-for-python-code-generation-5-best-tools-to-get-started
Best AI Python code generator tools: 5 top options for data analysis | Fabi.ai
GitHub Copilot: AI code generation assistant that plugs into all common IDEs. Best for seasoned software developers who don’t want to switch to a new IDE. Each AI Python code generator has its strengths, and the best tool depends on your workflow.
🌐
Zencoder
zencoder.ai › home › 8 best ai for python code generation tools in 2026
8 Best AI for Python Code Generation Tools in 2026
December 6, 2025 - For businesses, GitHub Copilot offers 2 Paid Plans starting at $19 per month. Cursor is an AI-powered code editor that enhances productivity through features like code generation, smart rewrites, and codebase queries.
🌐
GitHub
github.com › zerlok › gendalf
GitHub - zerlok/gendalf: Code-first, deterministic generator for type-safe Python transport and SQL adapters.
Gendalf is a Python code generation tool that simplifies the creation of transport layer code based on Domain-Driven Design (DDD) principles.
Author   zerlok
🌐
GitHub
github.com › topics › codegenerator
codegenerator · GitHub Topics
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage). django dsl metaprogramming codegenerator compilers autogenerated crud-apis ... ZoomBrute.py is a simple script that automatically tests random Zoom meeting codes, to brute force meetings. bruteforce codegenerator zoom brute bombing zoombombing zoombrute ... A translator Django into SQLAlchemy. python sqlalchemy django code-generator codegenerator codegen geodjango geoalchemy
🌐
GitHub
github.com › topics › ai-code-generator
ai-code-generator · GitHub Topics · GitHub
workflow awesome awesome-list cursor bolt awesome-ai ai-security ai-code-generator ai-tools ai-development-tools ai-development ai-developer ai-code-generation ai-developer-tools ai-coding-tools cursor-ai ai-coding vibe-coding ai-coding-assistant ai-devtools ... android kotlin java editor ai ide android-application code-editor collaborate contributions-welcome mobile-ide jetpack-compose ai-code-generator vcspace visual-code-space ... Llama-github is an open-source Python library that empowers LLM Chatbots, AI Agents, and Auto-dev Solutions to conduct Agentic RAG from actively selected GitHub public projects.
🌐
AnalytixLabs
analytixlabs.co.in › blog › ai-python-code-generator-tools
Python Code Generator: Top 15 AI Tools for Python Programming
February 4, 2026 - GitHub Copilot is the most common AI-powered coding agent developed by GitHub and OpenAI. It provides real-time coding suggestions, helping developers write efficient Python code.
🌐
Python
python.org › about › success › cog
Cog: A Code Generation Tool Written in Python
We could then use this general purpose tool to solve our specific generation problem. The tool I wrote is called Cog. Its requirements were: We needed to be able to perform interesting computation on the schema to create the code we needed. Cog would have to provide a powerful language to write the code generators in.
🌐
GitHub
github.com › topics › code-generators
code-generators · GitHub Topics · GitHub
Code generation tool, creates python / C programs that parse command line arguments.
🌐
GitHub
github.com › topics › code-generation
code-generation · GitHub Topics · GitHub
visualization go golang documentation benchmarking awesome static-analysis data-visualization tests developer-tools compilers awesome-list code-generation command-line-tool profiling code-visualization ... Multi-Language Vulkan/GL/GLES/EGL/GLX/WGL Loader-Generator based on the official specs. python c rust pascal opengl generator nim cpp vulkan d gles glx code-generation gl egl glad gles2 wgl loader-generator