On Mon, Sep 19, 2011 at 4:14 AM, Stan Schymanski <schym...@gmail.com> wrote:
> Dear Simon, Richard, Nils and Maarten,
>
> Thanks for putting so much thought into it. Unfortunately, most of what you
> are discussing is way beyond my horizon, so I can't really contribute. I had
> no clue how many things need to be considered before implementing my
> request.
>
> I just wanted to confirm that Simon summarised my request very accurately in
> the below text.
> Here is an example of a typical worksheet:
>
> var('T_a')    # Air temperature (K)
> var('T_l')    # Leaf temperature (K)
> var('R_ll')    # Longwave radiation away from leaf per unit projected leaf
[...]
> Thanks heaps for your ideas!

I don't know if anybody mentioned this exactly, but something like you
want is *already* done in Sage for units, and you can take advantage
of that.  Here's an example:

sage: T_a = sage.symbolic.units.UnitExpression(SR, var('T_a'));
T_a._sage_doc_ = lambda: "Air Temperature (K)"

Now when you introspect you get your docstring.  Watch:

sage: T_a?
...
Docstring:
    Air Temperature (K)
...

--------

You could put the above into a function:

def var2(name, doc):
    z = sage.symbolic.units.UnitExpression(SR, SR(name))
    z._sage_doc_ = lambda: str(doc)
    return z

Use it like this (make sure to assign to T_a):

sage: T_a = var2('T_a', 'Air Temperature (K)')

sage: T_a?
Air Temperature (K)

William

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to