Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76995

Re: Working with decimals part 2

References <hsomv9hvf31ntf45rr2ukhb0078cubovre@4ax.com>
Date 2014-08-26 04:16 +1000
Subject Re: Working with decimals part 2
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.13425.1408990569.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Aug 26, 2014 at 3:55 AM, Seymore4Head
<Seymore4Head@hotmail.invalid> wrote:
> For some reason, it is not working.  If I try to use row2 I get this
> error:
> http://i.imgur.com/FgeF9c9.jpg

Several meta-issues.

Firstly, your subject line talks about 'decimal' again. You're
actually working with floats; Python has a quite separate decimal
module, and it's not what you're doing here. It's confusing for those
of us who know that you're actually working in binary floating point
:)

Secondly: An image is a really bad way to capture an error message.
Instead of saying "it is not working" and uploading a screenshot to
imgur, just copy and paste the exception into the body of the email.

Thirdly: If you're working iteratively, keep the files as simple as
possible, and if you can do this as one-liners in Idle's interactive
mode, that's probably the easiest way to show us what's happening.
Don't bury all of them in together into a single program.

As to your actual issue... it's a little unclear, because the system's
interpretation of what you've written is completely different from
yours - due to one misplaced bracket.

>>> str(format(number), ',.2f'))

You want to format the number .2f, not str the formatted number .2f. I
think you can figure it out from there :)

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Working with decimals part 2 Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-25 13:55 -0400
  Re: Working with decimals part 2 Chris Angelico <rosuav@gmail.com> - 2014-08-26 04:16 +1000
  Re: Working with decimals part 2 Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-08-25 19:23 +0100
  Re: Working with decimals part 2 MRAB <python@mrabarnett.plus.com> - 2014-08-25 19:26 +0100
  Re: Working with decimals part 2 alex23 <wuwei23@gmail.com> - 2014-08-26 10:46 +1000
    Re: Working with decimals part 2 Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-08-27 19:55 -0400

csiph-web