On Sunday 07 September 2008, mmarco wrote: > Martin Albrecht ha escrito: > > Hi Miguel, > > > > can you be convinced to work on it some more? > > Sure > Hi there,
> I will take a look at it, considering your comments. The reason why i > didn't use most of what you suggested is because i didn't know about > it (i am new to sage). I will take a look at it and try to write a > revised version in the next days. Thanks, feel free to ask questions that arise during the process :-) > > 4) Injecting a variable into the global namespace in a function > > ('defining a') is bad practice, IMHO. It should be avoided. It is better > > to create a variable in the local scope and pass it on to eval. > > the reason why i did that is because i couldn't find a way to create a > variable that has the same name as the one used in the singular > polynomial. I agree it is not a desirable thing to create a variable > in the process, but it was the best i could find. How can i implement > what you suggest? Yes :-) sage_eval (and eval) accept additional parameters which are dictionaries with name object mappings: sage: K = NumberField(x^2 + 1,'a') sage: sage_eval("a+1",{K.variable_name():K.gen()}) a + 1 So you don't need to create such a variable, just pass in the correct mapping to the evaluation function. Cheers, Martin -- name: Martin Albrecht _pgp: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x8EF0DC99 _www: http://www.informatik.uni-bremen.de/~malb _jab: [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---