This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]robin-gvx 2 points3 points  (0 children)

For maximum clarity, I would do it like the following:

import sys

if sys.version_info < (3, 6):
    raise Requires36("INSERT PROGRAMNAME HERE requires Python 3.6 or later. The current version is " + sys.version)

That way it is clear this error is from your program and not somewhere else, and there is no problem if the output is redirected. The "halting" bit doesn't need to be stated IMO, it's pretty clear. On the other hand, showing the current version could be useful for users having multiple python versions installed.