Mike,
On Mon, Sep 8, 2008 at 7:40 PM, Mike Hansen you wrote:
>
> On Mon, Sep 8, 2008 at 3:43 PM, Bill Page wrote:
>> So far everything is looking good to me in your patch. :-) I wonder
>> if there is still time to get it into the next release of Sage?
>
> Yes, it should get in.
Is there anything specific I can do the help make sure it does?
> ...
>> Anyway, in general I am looking for a convenient and
>> natural way to access elements of Axiom type Record
>> and Union.
>
> You could still allow for the dot access like you had before with
> this inheritance caveat. Another option is to treat Records like
> dictionaries in Python so you'd make modifications to __getitem__
> to allow for things like g['order'] or g['function'].
>
I just discovered the method 'attribute' in ExpectElement:
def attribute(self, attrname):
"""
If this wraps the object x in the system, this returns the object
x.attrname. This is useful for some systems that have object
oriented attribute access notation.
EXAMPLES:
sage: g = gap('SO(1,4,7)')
sage: k = g.InvariantQuadraticForm()
sage: k.attribute('matrix')
[ [ 0*Z(7), Z(7)^0, 0*Z(7), 0*Z(7) ], [ 0*Z(7), 0*Z(7),
0*Z(7), 0*Z(7) ],
[ 0*Z(7), 0*Z(7), Z(7), 0*Z(7) ], [ 0*Z(7), 0*Z(7),
0*Z(7), Z(7)^0 ] ]
sage: e = gp('ellinit([0,-1,1,-10,-20])')
sage: e.attribute('j')
-122023936/161051
"""
...
With this I can write:
sage: g=axiom.guess([1,3,5,7,9])
sage: g.type()
List Record(function: Expression Integer,order: NonNegativeInteger)
sage: g[1].attribute('function')
n 2
[[x ]f(x): (x - 2x + 1)f(x) - x - 1= 0]
sage: g[1].attribute('order')
0
-------
Although it is not quite as compact and Pythonic as your suggestion,
this seems to do exactly what I wanted.
Regards,
Bill Page.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---