On 7/4/11 8:22 PM, kcrisman wrote:
Is this even possible?

Given code

@interact
def _(widget_1=...,widget_2=..,...):
     do some stuff

is it possible to somehow extract the first version that is displayed,
with the defaults?

Simple example:

@interact
def _(x=2):
    print x^2

I want the output

4

@interact
def f(x=2):
    print x^2

f() # gives 4

f(3) # gives 9

The original function is left intact, so you can just call it.


Harder example:

@interact
def _(f=x^2, a=(3,[2..10]), c = (2,6)):
      g(x)=f+a
      show(plot(g,(x,-c,c)))

This is harder since when the interact is run, ``a`` is a single number (by the autoguessing), but when the function itself is run, ``a`` is a tuple. Same problem for c. Maybe we should actually change the function that is returned to substitute in the default arguments, instead of just returning the function. That would be doable and reasonable, I think.

Thanks,

Jason


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

Reply via email to