On 3/26/13 1:44 PM, Jason Grout wrote:
On 3/26/13 1:38 PM, Jason Grout wrote:
On 3/26/13 12:35 PM, kcrisman wrote:


On Tuesday, March 26, 2013 12:14:02 PM UTC-4, jason wrote:

    On 3/26/13 11:06 AM, kcrisman wrote:
     > This is just a question mostly for Jason and William, who have
    both been
     > reimplementing interacts.
     >
     > Could the following syntax be (fruitfully) made to work?
     >
     > @interact
     > def _(x,y=2,1):
     >      x,y=x*x+3*y*y,x*y+y*x
     >      html("$%s^2-3\cdot%s^2=%s$"%(x,y,x^2-3*y^2))
     >
     > It seems very "Pythonic" in some ways but I assume that Python
    functions
     > in general don't accept this, so probably it's a bad idea to try
    to hack
     > it in.  But I thought I'd put it out there and risk the
ridicule :)
     >

    What are you thinking that the result should look like and how it
    should
    behave?


The same as

@interact
def _(x=2,y=1):

Oh, I see.  You're wanting something like def f((x,y)=(1,2)) to work,
right?  I'd cast my vote with sticking with python (which does not allow
that syntax).

I take that back.  I found the PEP I had been searching for.  That
syntax *is* allowed in Python 2:

http://www.python.org/dev/peps/pep-3113/

sage: def f((x,y)=(1,2)):
.....:     print x,y
.....:
sage: f((1,2))
1 2

but it is removed in Python 3.

In fact, both sage notebook and sage cell don't handle this correctly:

http://sagecell.sagemath.org/?q=4716a2dd-040e-428b-82f9-b799fe98cd9c

(and a similar error in the sage notebook).

I do suppose we could fix this, but the issue would most likely go away whenever we migrate to python 3.

Thanks,

Jason




--
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to