En Sat, 03 Feb 2007 07:35:22 -0300, Peter Otten <[EMAIL PROTECTED]> escribió:
> Gabriel Genellina wrote: > >> En Sat, 03 Feb 2007 06:12:33 -0300, Peter Otten <[EMAIL PROTECTED]> >> escribió: >> >>> John Nagle wrote: >>> >>> import warnings >>> warnings.filterwarnings("ignore", message="Old style callback, use >>> cb_func(ok, store) instead") >> >> Or you can be more aggressive and filter out all DeprecationWarnings: >> warnings.simplefilter("ignore",DeprecationWarning) >> (same as using option -Wignore::DeprecationWarning on the python command >> line) > > The latter might be interesting for a cgi. I didn't mention it because I > didn't get it to work with my test case (importing sre) and Python's cgi > server. Trying again, I found that you must not quote the -W argument. > > #!/usr/local/bin/python2.5 -Wignore:The sre module is deprecated, please > import re. > >> From that follows that you can pass at most one commandline arg. > If you are using > > #!/usr/bin/env python2.5 > > python2.5 will be that single argument and no options are possible at > all. > What might be the reasons for such a seemingly arbitrary limitation? The shell parses that line, not Python, so you should look into its documentation. If one needs to disable the warning for all scripts, putting a call to warnings.simplefilter on sitecustomize.py would help (of course, if one is allowed to edit that file). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list