Python's print statement was surface-level beautiful, with subsurface flaws:
1) it modified the file object's "softspace"
>>> class MyFile(object):
... softspace = "Hello"
... def write(self, s):
... pass
...
>>> f = MyFile()
>>> f.softspace
'Hello'
>>> print >>f, "spam"
>>> f.softspace
0
2) This wasn't a problem until >> was added, because of problem #2 - the print statement didn't originally let you print to anything other than stdout. Which meant that if you wanted to support writing to a file instead of a stdout then you had to re-implement print yourself.
In practice, I've also found that having print as a function adds functionality because I can do things like:
print(*data_values, sep="\n")
which is a quick way to print each value in a list on its own line.
1) it modified the file object's "softspace"
2) This wasn't a problem until >> was added, because of problem #2 - the print statement didn't originally let you print to anything other than stdout. Which meant that if you wanted to support writing to a file instead of a stdout then you had to re-implement print yourself.In practice, I've also found that having print as a function adds functionality because I can do things like:
which is a quick way to print each value in a list on its own line.