I wrote a module that, if it is imported, automatically changes the error output of my program. It is quite handy to have it in almost any python code I write.
Thus I don't want to add the line import my_errorhook to every code I write but want to have this line added automatically.
I found this answer, stating that it should be avoided to change the behavior of python directly. So I thought about changing the command line, something like
python --importModule my_errorhook main.py
and defining an alias in the bashrc to overwrite the python command to automatically add the parameter. Is there any way I could achieve such a behavior?
python_error something like that and keep yourpythoncommand too.my_errorhookwhen reading the main code, since the errorhook only affects error output. BTW, if you use the Python REPL frequently you could addmy_errorhookto a startup script named in PYTHONSTARTUP.python --helpin the terminal, it's also mentioned near the start of the official tutorial. FWIW, my startup script importsreadlineandrlcompleterso I get full editing with history and Tab completion in the REPL.