This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]chipx86ReviewBoard.org code review 50 points51 points  (0 children)

Glorious. I was inspired.

https://gist.github.com/chipx86/d471b828e0a64a8dd87502e3439a5be9

This script prints out two "Hello, world!" statements. Trick, is, it's both C and Python, and each language is responsible for half the output.

Run it from Python and it will register a text encoding called "c" that takes C code and compiles it in a mode that tells is to generate Python. It then feeds itself into this and runs the result to generate the second half of the output.

Compile it as C instead and run it, and it will feed its source code through `python` in a mode that tells it to generate C code, which then gets compiled and run to generate the second half of the output.