Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Overridding print()

I'm using mod_wsgi and was wondering if it's possible to over-write the print() command (since it's useless).

Doing this doesn't work:

print = myPrintFunction

Since it's a syntax error. :(

like image 732
Ian Avatar asked Nov 30 '22 20:11

Ian


1 Answers

Print is not a function in Python 2.x, so this is not directly possible.

You can, however, override sys.stdout.

If you are on Python 3.0 in which print is now a function what you have would then work, assuming you have the right signature. Also see a related question in this site.

like image 165
Paolo Bergantino Avatar answered Dec 22 '22 02:12

Paolo Bergantino