polyglot-c-py
Installation
SKILL.md
Polyglot C-Python File Creation
This skill provides guidance for creating single source files that function correctly as both Python and C programs.
When to Use
This skill applies when:
- Creating a file that must be valid syntax for both Python and C
- The file needs to execute correctly under both
python filenameandgcc filename && ./output - Building polyglot programs that produce equivalent output in both languages
Polyglot Structure Approach
Core Technique
Use preprocessor directives and string literals to hide language-specific code:
- Hide C code from Python: Wrap C-specific code in triple-quoted strings that Python ignores
- Hide Python code from C: Use
#if 0...#endifpreprocessor blocks that C ignores but Python sees as comments