Hi guys, Thanks for the insights. I knew that trying to define the generators in my original way was asking for trouble, but it's good to learn why. Right now, I just did the simple thing (which I should have done from the start):
class DifferentialForms(Algebra): def __init__(..., coordinates = ('x', 'y', 'z')): # Create a dz for every z in coordinates This way I can avoid any confusion with the 'names' keyword. The "preparse" command is pretty cool! All the best, Joris On 18 mei, 18:30, Jason Grout <jason-s...@creativetrax.com> wrote: > On 05/18/2010 11:14 AM, John Cremona wrote: > > > In our example, how does DifferentialForms() know that there are three > > variables? > > > Also, note that the syntax F.<x,y,z> = ... would normally be a > > shorthand for something like F = ....; x,y,z = F.gens(). > > Good point. Joris, the <x,y,z> syntax is just syntactic sugar that is > preparsed into: > > sage: preparse('F.<x,y,z>=DifferentialForms()') > "F = DifferentialForms(names=('x', 'y', 'z',)); (x, y, z,) = > F._first_ngens(3)" > > So you can see from the "(x,y,z,)=..." statement that you are in reality > defining the variables "x", "y", and "z", and there is nothing a class > can do about that without changing the preparser. > > In fact, if I wanted to call what you call "dx" by the name "x", I > suppose that is my business, regardless of how many conventions it > messes up :). > > In that sense, would it be so hard to expect the user to do something like: > > F.<dx,dy,dz>=DifferentialForms() > > which preparses into > > sage: preparse('F.<dx,dy,dz>=DifferentialForms()') > "F = DifferentialForms(names=('dx', 'dy', 'dz',)); (dx, dy, dz,) = > F._first_ngens(3)" > > 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 athttp://groups.google.com/group/sage-devel > URL:http://www.sagemath.org -- 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