FINANCIAL MODELLING PACKAGE IN PYTHON?

Robin Becker robin at jessikat.demon.co.uk
Wed Jan 5 12:47:24 EST 2000


In article <1265040530-3892638 at hypernet.com>, Gordon McMillan
<gmcm at hypernet.com> writes
>Robin Becker wrote:
> > > |Also under
>> certain extreme circumstances my code would like to report a >
>> |total failure eg attempt to divide by error. I would like to ask
>> more > |experienced pythoneers how arithmetic errors are handled
>> using built in > |IEEE exceptions and how does one gracefully
>> crash a python script? (eg > |an abend/abort). 
>
>> >raise
>> ArithmeticError, "Oops" >raise ZeroDivisionError, "Ouch" > >? >
>
>> yes that's python, but what's the best way to do it in an
>> existing C library? -- Robin Becker
>
>PyErr_SetString(PyExc_ZeroDivisionError, "Ouch");
>return NULL;
>
>(see bltinmodule.c for the complete list).
> 
>> -- 
>> http://www.python.org/mailman/listinfo/python-list
>
>
>
>- Gordon
>

I guess I could have made my query a bit clearer. When I call my
extension in C I can pass inputs which may cause unexpected arithmetic
exceptions. That's an efficiency saving. I could check every arithmetic
op. Assuming I want speed is there a standard pythonic way eg
signal+setjmp/longjmp to trap these errors?

 In the VBA interface I have implemented exception trapping using VC++
__try blocks (I seem to remember this was because of Excel somehow).

The current C uses a pair of global functions to handle I/O to
stdout/err. What's a good way to provide pythonic output for a C
extension module?

One other thing I am a bit uncertain about is threading. If I call
python inside my C extension must I worry about threading issues for the
extension?
-- 
Robin Becker



More information about the Python-list mailing list