Hello, I'm working at fixing issue 888. It is easy to fix but I don't understand why in sympy/utilities/lambdify.py I found that lambdastr function does use __str__ for expr.
def lambdastr(args, expr): """ Returns a string that can be evaluated to a lambda function. >>> from sympy import symbols >>> x,y,z = symbols('xyz') >>> lambdastr(x, x**2) 'lambda x: (x**2)' >>> lambdastr((x,y,z), [z,y,x]) 'lambda x,y,z: ([z, y, x])' """ # Transform everything to strings. expr = str(expr) if isinstance(args, str): pass elif hasattr(args, "__iter__"): args = ",".join(str(a) for a in args) else: args = str(args) return "lambda %s: (%s)" % (args, expr) But in python doc we can read: (http://docs.python.org/ref/customization.html) ################################ __repr__( self) Called by the repr() built-in function and by string conversions (reverse quotes) to compute the ``official'' string representation of an object. If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment). If this is not possible, a string of the form "<...some useful description...>" should be returned. The return value must be a string object. If a class defines __repr__() but not __str__(), then __repr__() is also used when an ``informal'' string representation of instances of that class is required. This is typically used for debugging, so it is important that the representation is information-rich and unambiguous. __str__( self) Called by the str() built-in function and by the print statement to compute the ``informal'' string representation of an object. This differs from __repr__() in that it does not have to be a valid Python expression: a more convenient or concise representation may be used instead. The return value must be a string object. ################################ As I understand __repr__ should be used to have a pythonic valid expression and __str__ should be a normal string. But sympy Basic __repr__ implementation returns unicode text with repr_level_2 so we can't use it in eval(). This is also discussed in issue 697. I suggest to change this behaviour, so we can make lambdify more robust. Is someone working at this? Thank you Riccardo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---