addPyToM2Function(type, f, desc)Most of the hooks used by value have the same general format: if the python object has a particular type, then use a particular function to convert it to a corresponding Macaulay2 thing. This function simplifies the process of adding such a hook.
For example, suppose we would like to convert Fraction objects from the Python fractions module to QQ objects. Without adding a hook, value will convert these objects to RR objects.
|
|
|
So we write a function to do the conversion and then install the hook using addPyToM2Function.
|
|
|
|
The object addPyToM2Function is a method function.
The source of this document is in /build/macaulay2-88fgJW/macaulay2-1.25.11+ds/M2/Macaulay2/packages/Python/doc.m2:471:0.