I searched around and couldn't find an answer to this either on this site or elsewhere (always a challenge searching for topics involving punctuation chars).
I was looking up the StringIO
in the Python standard library (here) and one of the examples is this (excerpt):
import StringIO
output = StringIO.StringIO()
output.write('First line.\n')
print >>output, 'Second line.' # <-- This is the line I'm asking about
How or why does the >>
operator work here? As far as I can tell (and I'm no Python expert), this is the right shift operator. I thought perhaps StringIO
overrides __rshift__
or something, but the source for StringIO does not betray any such thing.
I haven't poked around to see how the print
built-in is implemented yet, but with initial searching I'm unable to figure out how this works. Anyone?