Re: Mutable complex numbers [was Re: output formatting for classes]

2006-03-11 Thread Schüle Daniel
Steven D'Aprano wrote: > On Fri, 10 Mar 2006 02:19:10 +0100, Schüle Daniel wrote: > > >>yeah, i miss some things in complex implementation >>for example c=complex() >>c.abs = 2**0.5 >>c.angle = pi/2 >> >>should result in 1+1j :) > > > Smiley noted, but consider: > > c = complex() > => what is

Mutable complex numbers [was Re: output formatting for classes]

2006-03-10 Thread Steven D'Aprano
On Fri, 10 Mar 2006 02:19:10 +0100, Schüle Daniel wrote: > yeah, i miss some things in complex implementation > for example c=complex() > c.abs = 2**0.5 > c.angle = pi/2 > > should result in 1+1j :) Smiley noted, but consider: c = complex() => what is the value of c here? c.abs = 2**0.5 => wha

Re: output formatting for classes

2006-03-09 Thread Schüle Daniel
Russ wrote: > I'd like to get output formatting for my own classes that mimics the > built-in output formatting. For example, > > x = 4.54 print "%4.2f" % x > > 4.54 > > In other words, if I substitute a class instance for "x" above, I'd > like to make the format string apply to an elem

output formatting for classes

2006-03-09 Thread Russ
I'd like to get output formatting for my own classes that mimics the built-in output formatting. For example, >>> x = 4.54 >>> print "%4.2f" % x 4.54 In other words, if I substitute a class instance for "x" above, I'd like to make the format string apply to an element or elements of the instance.