Re: Access to formatting controls from within __repr__ or __str__?

2005-02-19 Thread Serge Orlov
Dan Sommers wrote: > On 18 Feb 2005 01:25:06 -0800, > "Serge Orlov" <[EMAIL PROTECTED]> wrote: > >> Dan Sommers wrote: > >>> So my question is: Is there a way to pass options "through" a >>> format string to the __str__ and __repr__ functions? For example, >>> can I define my own alternate form f

Re: Access to formatting controls from within __repr__ or __str__?

2005-02-18 Thread Dan Sommers
On 18 Feb 2005 01:25:06 -0800, "Serge Orlov" <[EMAIL PROTECTED]> wrote: > Dan Sommers wrote: >> So my question is: Is there a way to pass options "through" a format >> string to the __str__ and __repr__ functions? For example, can I >> define my own alternate form for use with the '#' formattin

Re: Access to formatting controls from within __repr__ or __str__?

2005-02-18 Thread Serge Orlov
Dan Sommers wrote: > So my question is: Is there a way to pass options "through" a format > string to the __str__ and __repr__ functions? For example, can I > define my own alternate form for use with the '#' formatting > character, so that '%#s' generates output according to SI guidelines? Yo

Access to formatting controls from within __repr__ or __str__?

2005-02-17 Thread Dan Sommers
Hi, I have a class whose objects represent physical quantities including uncertainties and units, and I would like more control over the way they print. I have a __str__ method which outputs the quantity and its uncertainty, properly rounded (i.e. the uncertainty to one digit and the quantity to