On Fri, Mar 9, 2012 at 1:12 PM, kcrisman <[email protected]> wrote: > > > On Mar 9, 2:49 pm, Matt Noonan <[email protected]> wrote: >> Hello all, >> >> I have enjoyed using Sage while teaching several classes now, finding >> it especially terrific for linear algebra and differential equations. >> But one barrier to entry for my students has been keeping track of >> what is a function and what is a method. Since most of the students >> do not have a background in computer science, I think the idea of a >> method (or even an object) is a bit foreign to them, and the notation >> seems obscure. >> >> To hopefully ease these problems, I've been writing a little bit of >> code which automatically converts failed function calls into method >> calls. For example, you can now write >> >> A = matrix([[1,2],[3,4]]) >> print eigenvalues(A) >> >> and get a result which is equivalent to writing >> >> print A.eigenvalues() >> >> Yet the code >> >> B = vector([1,2]) >> print eigenvalues(B) >> >> would fail with a NameError. In fact, "eigenvalues" isn't even in the >> namespace here. > > Oh, how I wish you would have emailed here first! This is already > *in* Sage. See > http://ask.sagemath.org/question/559/how-to-magically-define-variables-and-use > . Apparently this is only available in the notebook, by the way - > according to the ticket where William did this, "I could not figure
I didn't use the AST at all, so my implementation is totally different than the OP's. Hence there could be some interest in comparing. Mine just does a stupid (?) try/except or something... -- William > out how to implement this on the command line without making > potentially major changes to IPython, which is a bad idea at this > point." Perhaps things in IPython have changed, perhaps not. > > Maybe we should advertise this more. One of the pedagogical issues in > question (hence cc:ing to sage-edu) is that we *do* eventually want > students to get more sophisticated, and so I have been careful *not* > to use this. Especially math and science majors are almost guaranteed > to need to know how to program if they do not go into education, and > it's a boon to them if they do, so knowing the OO paradigm (even if > they don't call it that) can be useful. > > - kcrisman > > -- > You received this message because you are subscribed to the Google Groups > "sage-edu" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sage-edu?hl=en. > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- You received this message because you are subscribed to the Google Groups "sage-edu" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sage-edu?hl=en.
