Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Need to find the source code for print or printf in python [closed]

I am working on something that I cannot entirely talk about. All I can say is that I am a student in Information Security and Computer Science.

I simply need to change some source code of something deep inside python. For now, I would specifically like to change source code inside the builtin print function. Unfortunately, I can't find it defined any where in the python source code files.

Any ideas whatsoever?

Thanks very much.

EDIT: Specifically the question intended to ask if the print function in Python could be overwritten with something else. This was intended as to plant a backdoor in the Python interpreter.

like image 755
p0lAris Avatar asked Oct 27 '12 08:10

p0lAris


1 Answers

In cpython, the print function is implemented in C, not Python. You can find the source code here, but you'll have to recompile cpython in order for changes to take effect.

For an implementation of print in Python, have a look at pypy's version.

like image 145
phihag Avatar answered Sep 17 '22 23:09

phihag