I'm writing a python program for some time and I have a lot of code. Mainly, I use printing statements and writing into files for debugging purposes.
Because I do not want all the time to do debug I made some flags on top of the file "print_info = False" or "print_to_file = False ". The problem here is that my code looks like that
if print_to_file:
write_file("blah")
if print_info :
print("blah")
...
...
if print_to_file:
write_file("blah blah")
if print_info :
print("blah blah blah")
I felt that the code looks a little bit unprofessional and I made some methods but stil I do not like it:
print_useful_info_to_file(info):
if print_to_file:
write_file(info)
print_debug_method(info):
if print_to_file:
write_file(info)
if print_info :
print(info)
Is there any good practice how to write this in a beautiful manner?
Thanks
Aucun commentaire:
Enregistrer un commentaire