[Numpy-discussion] npfile deprecation warning

Brennan Williams brennan.williams@visualreservoir....
Mon Jun 15 18:48:40 CDT 2009


Robert Kern wrote:
> On Mon, Jun 15, 2009 at 17:27, Brennan
> Williams<brennan.williams@visualreservoir.com> wrote:
>   
>> Hi
>>
>> I'm using npfile which is giving me a deprecation warning. For the time
>> being I want to continue using it but I would like to suppress
>> the warning messages. Is it possible to trap the deprecation warning but
>> still have the npfile go ahead?
>>     
>
> http://docs.python.org/library/warnings
>
>   
Thanks.
OK I've put the following in my code...

import warnings

def fxn():
    warnings.warn("deprecated", DeprecationWarning)

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fxn()




but I'm getting an invalid syntax error...

with warnings.catch_warnings():
                       ^
SyntaxError: invalid syntax

I haven't used "with" before. Is this supposed to go in the function def 
where I use npfile? I've put it near the top of my .py file after my 
imports and before my class definitions.

btw I'm using Python 2.5.4
 
Brennan




More information about the Numpy-discussion mailing list