ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 03 Jan 2017 14:15:23 -0600get short name for QQ, RDF, AA etchttp://ask.sagemath.org/question/36150/get-short-name-for-qq-rdf-aa-etc/ I wonder whether there is a way to get back the *short name of the function* of the various rings and fields like QQ, RDF, AA, RLF, RR, etc. as a string.
For example
sage: a=QQ
sage: str(a)
'Rational Field'
But I am looking for something like:
sage: function_I_want(a)
'QQ'
I guess I could predefine a dictionary like this:
shortnames={eval(name):name for name in ['QQ', 'RDF', 'AA', 'RLF', 'RR']}
and then have a function
def function_I_want(a):
return shortnames[a]
But this seems a bit clumsy. Is there a better way to do this; or is there somewhere in the sage code such a dictionary already defined?
The reason I am thinking about this is the following tiny bug:
https://trac.sagemath.org/ticket/22132
mfTue, 03 Jan 2017 14:15:23 -0600http://ask.sagemath.org/question/36150/