Message 300566 - Python tracker (original) (raw)

The condition we (mostly Serhiy) came up with for the check is actually kinda neat, since it's based on the value of the LHS and is hard to trigger accidentally:

>>> printf = print
>>> print = 10
>>> print >> 1
5
>>> printf >> 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and 'int'. Did you mean "print(<message>, file=<output_stream>)"

Anyway, I'll put together a PR that combines both the original patch and the follow up fix to add the missing question mark.