I am introducing the loggers into my project and I would like to ban the print statement usage in it. My intent is to force any future developers to use the loggers and to make sure I replaced all print invocations in project.
So far I managed to restrict print('foo')
and print 'foo'
like invocations with:
from __future__ import print_function
def print(*args, **kwargs):
raise SyntaxError("Don't use print! Use logger instead.")
But it is still possible to use print
without arguments with intent of adding newline but it won't do anything.
Is it possible to do it without interpreter modifications?
EDIT: I wasn't clear enough I guess from the comments. I just wanted to know if I can prevent the print function for being aliased
print("foo") # raises exception
print "foo" # doesn't work either
print # doesn't raise any exception, but I want it to
foo = print # this shouldn't work either like the one above, but it does