On 2014-10-01, Simon King <[email protected]> wrote:
> Hi!
>
> I wonder: How does one access the fields of a record that is defined in
> libgap? If R is a record in GAP and f is one of its fields, then it can
> be accessed by R.f; however, this does not work in libgap:
>
>   sage: R = libgap.eval('rec(a:=1, b:=2)')
>   sage: R.RecFields()   # So, creating the record did work
>   [ "b", "a" ]

R is a Python dictionary.
So you just can do

R["a"]
and get 1, 

etc.

>   sage: R.a
>   Traceback (most recent call last)
>   ...
>   AttributeError: name "a" is not defined in GAP.
>
> In the GAP pexpect interface, the following would work:
>
>   sage: R = gap('rec(a:=1, b:=2)')
>   sage: gap('{}.a'.format(R.name()))
>   1
>
> But that's awkward and moreover won't work in libgap.
>
> Best regards,
> Simon
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to