Instead of a simple debug/log print as this:
print "error ", error_number
I would like to use a log function that I can expand when required looking something like this:
def log(condition, *message):
if(<do something here...>):
print(*message)
<perhaps do something more...>
and call it like this:
log(condition, "error ", error_number)
But I get the following syntax error:
print *message
^ SyntaxError: invalid syntax
Is it a limitation of the print function or is there some way to make it work? If not, is there an equivalent to print that I could use?
I'm using Python 2.7 by the way...
print
is not a function in Python 2.x. In the first snippet you are printing a tuple and the last one has invalid syntax. If you want to use the print function, you need to enable it via from __future__ import print_function
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With