Is there a way to globally set the sep-parameter of the print-function?
I'm getting tired of always doing this manually for every print-statement:
Simple example
some_superlong_list : List # existing list-object with A LOT of elements
print(*some_superlong_list, sep ="\n")
# do something with some_super_long_list
print("IDs:",*map(id.some_superlong_list),sep = "\n")
print("new values:",*some_super_long_list,sep = "\n")
Of course, I could add a shortcut sep = "\n", but I'd still have to assign the sep-parameter for each print-statement.
Is there a way to do something like this?
print.sep = "\n" # something like this, to set the sep-parameter to "\n" by default
CodePudding user response:
Inspired by this answer:
from functools import partial
println = partial(print, sep='\n')
then you can use println whenever you want the line separation.
