[issue30597] Show expected input in custom "print" error message

Nick Coghlan report at bugs.python.org
Thu Jun 8 08:57:53 EDT 2017


Nick Coghlan added the comment:

Those are easy enough to check with strncmp() even in C, so we could make them manageable by just including "<expr>" in the error message, rather than the full text of the original statement.

That is:

    Did you mean 'print(<expr>)'?                 # Default 
    Did you mean 'print(<expr>, file=<stream>)'?  # starts with '>>'
    Did you mean 'print(<expr>, end=' ')'?        # ends with ','

That's basically correct even when printing multiple arguments, so I'd avoid the temptation to detect commas within the line (particularly since they might be inside a string).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue30597>
_______________________________________


More information about the Python-bugs-list mailing list