openmath/convert_pickle.py
def OMDict(self, items):
        """
        Convert a dictionary (or list of items thereof) of OM objects into an OM object

        EXAMPLES::

            >>> from openmath import openmath as om
            >>> from openmath.convert_pickle  import PickleConverter
            >>> converter = PickleConverter()
            >>> a = om.OMInteger(1)
            >>> b = om.OMInteger(3)
            >>> o = converter.OMDict([(a,b), (b,b)]); print(o)
            OMApplication(
              elem=OMSymbol(name='dict', cd='Python', cdbase='http://python.org/'),
              arguments=[
                OMApplication(
                  elem=OMSymbol(name='tuple', cd='Python', cdbase='http://python.org/'),
                  arguments=[
                    OMInteger(integer=1),
                    OMInteger(integer=3)]),
                OMApplication(
                  elem=OMSymbol(name='tuple', cd='Python', cdbase='http://python.org/'),
                  arguments=[
                    OMInteger(integer=3),
                    OMInteger(integer=3)])])
            >>> converter.to_python(o)
            {1: 3, 3: 3}
        """
        return om.OMApplication(elem=self.OMSymbol(module='Python', name='dict'),
                                arguments=[self.OMTuple(item) for item in items])
def OMDict(self, items):
        """
        Convert a dictionary (or list of items thereof) of OM objects into an OM object

        EXAMPLES::

            >>> from openmath import openmath as om
            >>> from openmath.convert_pickle  import PickleConverter
            >>> converter = PickleConverter()
            >>> a = om.OMInteger(1)
            >>> b = om.OMInteger(3)
            >>> o = converter.OMDict([(a,b), (b,b)]); print(o)
            OMApplication(
              elem=OMSymbol(name='dict', cd='Python', cdbase='http://python.org/'),
              arguments=[
                OMApplication(
                  elem=OMSymbol(name='tuple', cd='Python', cdbase='http://python.org/'),
                  arguments=[
                    OMInteger(integer=1),
                    OMInteger(integer=3)]),
                OMApplication(
                  elem=OMSymbol(name='tuple', cd='Python', cdbase='http://python.org/'),
                  arguments=[
                    OMInteger(integer=3),
                    OMInteger(integer=3)])])
            >>> converter.to_python(o)
            {1: 3, 3: 3}
        """
        return om.OMApplication(elem=self.OMSymbol(module='Python', name='dict'),
                                arguments=[self.OMTuple(item) for item in items])
Convert a dictionary (or list of items thereof) of OM objects into an OM object

        EXAMPLES::

            >>> from openmath import openmath as om
            >>> from openmath.convert_pickle  import PickleConverter
            >>> converter = PickleConverter()
            >>> a = om.OMInteger(1)
            >>> b = om.OMInteger(3)
            >>> o = converter.OMDict([(a,b), (b,b)]); print(o)
            OMApplication(
              elem=OMSymbol(name='dict', cd='Python', cdbase='http://python.org/'),
              arguments=[
                OMApplication(
                  elem=OMSymbol(name='tuple', cd='Python', cdbase='http://python.org/'),
                  arguments=[
                    OMInteger(integer=1),
                    OMInteger(integer=3)]),
                OMApplication(
                  elem=OMSymbol(name='tuple', cd='Python', cdbase='http://python.org/'),
                  arguments=[
                    OMInteger(integer=3),
                    OMInteger(integer=3)])])
            >>> converter.to_python(o)
            {1: 3, 3: 3}