diff --git a/src/sage/libs/gap/context_managers.py b/src/sage/libs/gap/context_managers.py index cf7ebb222ed..517670c99f5 100644 --- a/src/sage/libs/gap/context_managers.py +++ b/src/sage/libs/gap/context_managers.py @@ -13,7 +13,7 @@ sage: with libgap.global_context('FooBar', 'test'): ....: print libgap.get_global('FooBar') - "test" + test Afterward, the global variable reverts to the previous value:: @@ -27,7 +27,7 @@ ....: raise ValueError(libgap.get_global('FooBar')) Traceback (most recent call last): ... - ValueError: "test" + ValueError: test sage: print libgap.get_global('FooBar') 123 """ diff --git a/src/sage/libs/gap/element.pyx b/src/sage/libs/gap/element.pyx index a62734b71d5..a9a39ad224e 100644 --- a/src/sage/libs/gap/element.pyx +++ b/src/sage/libs/gap/element.pyx @@ -1861,15 +1861,18 @@ cdef class GapElement_String(GapElement): sage: s = libgap('string') sage: type(s) + sage: s + "string" + sage: print s + string """ - - def sage(self): + def __str__(self): r""" - Return the Sage equivalent of the :class:`GapElement` + Convert this :class:`GapElement_String` to a Python string. OUTPUT: - A Python list. + A Python string. EXAMPLES:: @@ -1877,6 +1880,8 @@ cdef class GapElement_String(GapElement): "string" sage: type(_) + sage: str(s) + 'string' sage: s.sage() 'string' sage: type(_) @@ -1887,7 +1892,7 @@ cdef class GapElement_String(GapElement): libgap_exit() return s - __str__ = sage + sage = __str__ ############################################################################ ### GapElement_Function ####################################################