Skip to content

the mechanism for registering converters didn't work for me #27

@MarcoCostantini

Description

@MarcoCostantini

I tried the example at the bottom of page https://github.com/OpenMath/py-openmath: I tried to copy and paste each line, but it didn't work for me:

Finally, this class contains a mechanism for registering converters.
$ python3
Python 3.8.2 (default, Mar 13 2020, 10:14:16)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from fractions import Fraction
>>> from openmath import openmath as om
>>> from openmath.convert import DefaultConverter as converter
>>> def to_om_rat(obj):
...     return om.OMApplication(om.OMSymbol('rational', cd='nums1'),
...             list(map(converter.to_openmath, [obj.numerator, obj.denominator])))
...
>>> def to_py_rat(obj):
...     return Fraction(converter.to_python(obj.arguments[0]), converter.to_python(obj.arguments[1]))
...
>>> converter.register(Fraction, to_om_rat, 'nums1', 'rational', to_py_rat)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'BasicPythonConverter' object has no attribute 'register'
>>>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions