Is there a way to do the following preprocessor directives in Python?
#if DEBUG < do some code > #else < do some other code > #endif
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.
There’s
__debug__, which is a special value that the compiler does preprocess.__debug__will be replaced with a constant 0 or 1 by the compiler, and the optimizer will remove anyif 0:lines before your source is interpreted.