I would like a copy of the print function that is called debug. How can I alias a function in Python?
I would like a copy of the print function that is called debug .
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can simply assign
debug = printin Python 3.In Python 2
printisn’t a function. There no way to give yourself adebugstatement that works exactly likeprint(print 1,,print 1 >> sys.stderretc.). Best you can do is write a wrapper around theprintstatement:You can also disable the
printstatement and use the Python 3 version:If you do this, you cannot use the statement version (
print x) anymore. It’s probably the way to go if you’re not breaking any old code.