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 filename and gcc 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:

  1. Hide C code from Python: Wrap C-specific code in triple-quoted strings that Python ignores
  2. Hide Python code from C: Use #if 0...#endif preprocessor blocks that C ignores but Python sees as comments
Related skills

More from letta-ai/skills

Installs
34
Repository
letta-ai/skills
GitHub Stars
97
First Seen
Jan 24, 2026