import warnings
warnings.warn("Warning...........Message")
See the python documentation: here
Answer from necromancer on Stack OverflowRaise ValueError - including variables in the error message
Python `unittest` how can it ignore specific warnings?
When should I use logger.error vs raise exception?
It depends on what's expected from both you and the user's perspective. If you're writing a nice utility meant to be shared with the world, you often want it to display its problems in a nice fashion instead of crashing altogether (we all know this from using software ourselves, especially tools and utility programs). Crashing the program because you entered 3,1 instead of 3.1 is nothing anyone is looking for.
However if you mean to write a very simple program, especially meant for the command line, then it's often preferred to either work or fail altogether without 'pretending' nothing bad happened (which is shit for scripting it as the user needs to know where to look if it wants to know it actually worked).
The middle ground is the hardest part though. For command line tools I normally catch expected exceptions and return some clear explanation, but don't catch anything else, I'll let the user check what's going on if it does fail.
More on reddit.com