On 3/29/12 9:21 AM, Jason Grout wrote:

Make all input_box defaults go through the adapter
==================================================

Current Behavior: If a Sage object is specified as a default value, it
is explicitly used as the default value. The adapter is *not* run on the
default value.

Proposal: In most cases (except type=str input boxes), repr the default
object, and use a default adapter that involves a call to sage_eval.
Apply the adapter to the repr of the default. This means that the
default value is treated in exactly the same way as user input.

After the conversation with KDC and thinking more about things, here's a simpler and more backward-compatible rule:

If the default object is a string, it is as if the user typed that string into the input box. If the default object is not a string, then repr is called on the default object to get the default string.

This means that this example:

@interact
def _(n=input_box("identity_matrix(2)")):
    print n

will have n inside the function be an actual Sage identity matrix, and not have single quotes (like my original proposal).

Any comments?

Thanks,

Jason


--
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