On 8/13/07, David Joyner <[EMAIL PROTECTED]> wrote:
> I am probably missing something basic, but I cannot
> find the way to recover the name of a function. For example,
>
> x = var('x')
> f = function('hello', x)
>
> I'd like a method (name, say) which returns the
> string "hello", so something like:
> sage: f.name()
> 'hello'
> should work. My ugly hack is the following:
>
> sage: x = var('x')
> sage: f = function('hello', x)
> sage: f(x)
> hello(x)
> sage: vars = [f,x]
> sage: name = vars[0]._repr_()[0:(len(vars[0]._repr_())-2-len(str(vars[1])))]
> sage: name
> 'hello'
One could use blah._f._name, as illustrated below:
sage: x = var('x')
sage: g = function('hello', x)
sage: g
hello(x)
sage: g._f._name
'hello'
Or apply the patch here which makes .name() work as you requested:
http://sage.math.washington.edu/tmp/5733.patch
William
--~--~---------~--~----~------------~-------~--~----~
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/sage-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~----------~----~----~----~------~----~------~--~---