Access from gnumeric sheet to python 'Decimal'? [ solved ]

hi, pls. be tolerant with evtl. silly question …

[ edit ] think I found it myself, looks like you need to convert the python result into a float like:
‘return float( Decimal( ‘0.2’ ) + Decimal( ‘0.1’ )’ [ /edit ]

gnumeric has some interfacing / connection to python, ‘introspection’, the python console and ‘py_xxx’ functions for which some samples are provided and one can define customs in plugins/py-func/py_func.c .

In the python console I can use the sequence

>>> from decimal import *

>>> Decimal('0.2') + Decimal('0.1')

and get back Decimal(‘0.3’)

but I couldn’t manage to use similar from sheet. I have formulated a function ‘py_add’ which I can use in gnumeric sheet and works with other datatypes, adding constants, variables or even referenced cells.

Trying ‘from decimal import *’ in the header of py_func.c and even simple ‘return(Decimal(‘0.2’) + Decimal(‘0.1’)’ results in
'Unsupported Python type: <class 'decimal.Decimal'>
Anybody an idea what I’m doing wrong? TIA for any help.

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.