[Numpy-discussion] numpy error handling
rob at hooft.net
Sat Apr 1 22:38:04 CST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Travis Oliphant wrote:
| save = numpy.seterr(dividebyzero='warn')
Most of this discussion is outside of my scope, but I have programmed
this kind of pattern in a different way before:
~ save = context.push(something)
~ del save
i.e. the destructor of the saved context object restores the old
situation. In most cases it will be called by letting "save" go out of
scope. I know that relying on timely object destruction can be
troublesome when porting to Jython, but it is very convenient in CPython.
If that goes too far, one could make a separate method on save:
This can do sanity checking too (are we really at the top of the stack?
Only called once?). The destructor should check whether pop has been called.
Rob W.W. Hooft || rob at hooft.net || http://www.hooft.net/people/rob/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v126.96.36.199 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
More information about the Numpy-discussion