This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author aubmoon
Recipients BreamoreBoy, aubmoon, eric.smith, mark.dickinson, ned.deily, skrah
Date 2014-03-03.14:40:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <CAM8Gk7qAgmtQVp4sDXqfX7ji0d5amNf_5jpop1NoAA3=ubn-cg@mail.gmail.com>
In-reply-to <1393715820.5.0.370772685893.issue20811@psf.upfronthosting.co.za>
Content
We will add extending the float class as another possible work around or
part of a work around. Our developers now have a few options to
choose from. I am not sure which approach will be preferred. thanks for all
of the quick replies. this was just an odd case that was encountered, so I
wanted the community to be aware of it. if and when to address it is above
my level.

On Saturday, March 1, 2014, Eric V. Smith <report@bugs.python.org> wrote:

>
> Eric V. Smith added the comment:
>
> I still think this is a special case that we won't "fix". And even if we
> did, you'd have to wait until 3.5.
>
> But instead of your solution, it might be easier to wrap your floats in a
> class that implements your version of format, based on float's format with
> some post-processing:
>
> class MyFloat(float):
>     def __format__(self, fmt):
>         s = float.__format__(self, fmt)
>         if s[1] == '0':
>             return s[0] + s[2:]
>         return s
>
> print(format(MyFloat(0.12345678), '+8.8'))
> print(format(MyFloat(1.12345678), '+8.8'))
>
> gives:
> +.12345678
> +1.1234568
>
> I've grossly simplified __format__, of course. And I'm using built-in
> format() instead of ''.format() (because it's less typing), but they use
> the same mechanisms. So:
>
> print('{}:"{:+10.8}"'.format('answer', MyFloat(0.12345678)))
>
> gives:
> answer:"+.12345678"
>
> ----------
>
> _______________________________________
> Python tracker <report@bugs.python.org <javascript:;>>
> <http://bugs.python.org/issue20811>
> _______________________________________
>
History
Date User Action Args
2014-03-03 14:40:13aubmoonsetrecipients: + aubmoon, mark.dickinson, eric.smith, ned.deily, skrah, BreamoreBoy
2014-03-03 14:40:13aubmoonlinkissue20811 messages
2014-03-03 14:40:12aubmooncreate