Q's on my first python script

Marius Gedminas mgedmin at gmail.com
Thu May 14 18:18:54 EDT 2009


On May 10, 6:56 pm, Steven D'Aprano <st... at REMOVE-THIS-
cybersource.com.au> wrote:
> > 4. What's the python way to emit warnings?  (The script below should
> >    warn the user that arguments after the first one are ignored.)
>
> import warnings
> warnings.warn("The end of the world is coming!")

The warnings module is used for warnings about program code, not user
input.

import logging
logging.warn("Oh noes, you passed me two arguments instead of one!")

--
Marius Gedminas



More information about the Python-list mailing list