On Fri, Sep 19, 2008 at 4:26 AM, Stephen McInerney
<[EMAIL PROTECTED]>wrote:

>
> Why does the complex.__str__() method on complex numbers add the enclosing
> parentheses?
> It's unwanted, and it also makes them look like a tuple (other than the
> trailing comma).
> How can I get rid of it, other than the clunky:
>
> >>> print d
> (0.80-0.58j)
> >>> print repr(d)[1:-1]
> 0.80-0.58j
>
> How can I change complex.__str__() ?
>

>>> def printComp(comp):
...     comp = str(comp)
...     comp = comp.strip(')')
...     comp = comp.strip('(')
...     print comp
...
>>> printComp(d)
0.8-0.58j


That's the best I could come up with...
HTH,
Wayne
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to