TITLE: Converting GAP groups into SAGE permutation groups.
QUESTION [5 upvotes]: I have been working with SAGE online, and have made some programs to test some hypothesis about finite groups.  However, the pre-defined "named" groups in SAGE are quite limited (basically, the symmetric, dihedral, and alternating groups, plus PSL/PSU/PGUs and a couple sporadics).  SAGE evidently interfaces with GAP, so what I would like to do is pull some groups out of GAP's SmallGroups library so that I can run them through my SAGE code.
I am able to create a GAP group in SAGE with
A = gap.SmallGroup(27,4)

which returns
Group( [ f1, f2, f3 ] )

I can get its elements using
A.Elements()

which are then given to me in symbolic form, e.g.
[ <identity> of ..., f1, f2, f3, f1^2, f1*f2, f1*f3, f2^2, ... etc. ]

I just don't know how to turn these elements into permutations that SAGE can work with.  In other words, I want to take the gap.SmallGroup(27,4) and turn it into something of the form
Permutation Group with generators [(2,4,3), (1,3)(2,4), (1,4)(2,3)]

Could anyone show me how to do this?

REPLY [4 votes]: You can now do this easily (i.e. without string processing) in Sage:
A = gap.SmallGroup(27,4)    
PermutationGroup(gap_group = A.AsPermGroup())