You need to override __repr__. Due to a long standing Python "bug" (bug in
quotes because no one intends to ever fix it), str(list) calls repr() on
the elements instead of str().

Aaron Meurer


On Thu, Apr 25, 2013 at 6:03 PM, Alan Bromborsky <abro...@verizon.net>wrote:

> I have defined a new string printer as follows -
>
>
> from sympy.printing.str import StrPrinter
>
> half = Rational(1, 2)
>
>
> class SpecialStrPrinter(StrPrinter):
>
>     def _print_Function(self, expr):
>         name = expr.func.__name__
>         args = ", ".join([ self._print(arg) for arg in expr.args ])
>
>         if expr.func.nargs is not None:
>             if name in GA_Printer.function_names:
>                 return(expr.func.__name__ + "(%s)"%self.stringify(expr.**args,
> ", "))
>
>         return "%s" % (name,)
>
>     def _print_Derivative(self, expr):
>         diff_args = map(self._print,expr.args)
>         return 'D{%s}' % (diff_args[1],)+'%s' % (diff_args[0],)
>
>
> Basic.__str__ = lambda self: SpecialStrPrinter().doprint(**self)
>
>
> This work fine if I want to print a function or derivative of a function,
> but if
> I have a list of functions or list of derivatives of functions the
> printing of the
> elements of the list reverts to the standard string printer for functions
> and
> derivatives.  How do it get it to use my methods?
>
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to 
> sympy+unsubscribe@**googlegroups.com<sympy%2bunsubscr...@googlegroups.com>
> .
> To post to this group, send email to sympy@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/sympy?hl=en-US<http://groups.google.com/group/sympy?hl=en-US>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>

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


Reply via email to