In my quest to learn more regarding programming in Python, I "dissect" a lot of other people's code.
While doing this, or writing my own code, I end up with 10's of debug print lines.
Things like this: if v_Debug == 1: print("DEBUG - ".format()) # DEBUG
If I decide to keep the code for future use, those debug lines must eventually be removed, and that's not very fun at all.
So I decided to use what I had learned about writing self-modding code and create a module that would read thru
the calling module and delete those lines, and then save the altered file.
The code is the whole importable module. To use it, import your module of it, then call f_RemoveDEBUGLines()
with your pattern. The default pattern is "DEBUG". It will read the calling module's file and delete ALL the lines
that have the matching pattern.
Make sure you have a BACKUP of the original file, as you cannot undo what it does.
Note: I only share these snippets as a way to pay forward what I have gained from so many others.
My hope is that some will find these snippets and know what can be done, and how, like I so often
have and still do from other's efforts and posts.
Feel free to modify to your liking.
Enjoy