Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Huh, that’s convenient and really useful. When I do ridiculous import hacks, i usually just do it be importing a module, that trades the ast module to rewrite code, exec it and shim in an exit(). A preprocessor would be so much more ergonomic.

I used the ast rewriting stuff mostly before dicts were all ordered - replacing fist literals with an ordered dict call, which was actually useful.

I love how flexible python is. Most cursed thing I ever did was mutating strings in place, which led me eventually abusing mmap as well to write scripts that mutated themselves. Now I feel need to write lisp interpreter as a producer.



> mutating strings in place

They’re immutable. Were you directly writing to the memory location with ctypes or something?


Yep!




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: