Jason Swails wrote:
>> s = ('%%%ig' % sigfigs) % n # double-% cancels the %
Thanks! I see that the parenthesis can be dropped, too:
>>> '%%.%ig' % 3 % 4.23456e-5
'4.23e-05'
/c
--
http://mail.python.org/mailman/listinfo/python-list
I just sent a similar suggestion to tutor: check out the %g format.
>>> print '%g' % 1.2345e7
1.2345e+07
>>> print '%g' % 1.2345e-7
1.2345e-07
>>> print '%g' % 1.2345
1.2345
>>> def me(n, sigfigs = 4):
... s = ('%.'+'%ig' % sigfigs) % n # check docs for a better way?
... if 'e' in s: m, e = s.s
{Sorry about the no-wrap in the first post...}
I use the pywin environment on Windows for python code editing and
interactive environment.
I've been able to find the place in the editor files where the enter
key is handled and where the whitespace is stripped from a line and
I've been able
I use the pywin environment on Windows for python code editing and interactive
environment.
I've been able to find the place in the editor files where the enter key is
handled and where the whitespace is stripped from a line and I've been able to
get it to not leave any white space when a doub
The PyWin editor that comes with the Windows distribution is a great little
workhorse. If you have used it you perhaps notice how it intelligently works
with spaces and indentation, e.g. after typing the word 'pass' and pressing
enter it dedents one level as you would probably desire. It also st
> Hi,
> I'm trying to write a fairly basic text parser to split up scenes and
> acts in plays to put them into XML. I've managed to get the text split
> into the blocks of scenes and acts and returned correctly but I'm
> trying to refine this and get the relevant scene number when the split
> is ma
I happened across the recent discussion and found it very interesting as I have
been dusting off and trying to get ready a module that I had made that created
a number class that handled numeric values and uncertainties in computations by
computing (via overloaded operators) a new value and unce