Issue 2550559
Created on 2009-07-08 10:44 by ber, last changed 2022-08-23 13:30 by rouilj.
msg3750 |
Author: [hidden] (ber) |
Date: 2009-07-08 10:44 |
|
It would be nice to have a way to pretty print "Number"s.
It probably would be implemented in
roundup/cgi/templating.py class NumberHTMLProperty()
like
def pretty(self, format=_default)
similiar to the one for Date.
The use case is for attribues that are used as Integers
e.g. not displaying "90.0" and for numbers that are better shown
with spaces in front like amounts.
It could all be done with regular % python formatting.
Currently it cannot be done directly easily,
because the value can also be None, so __float__() from class Number
does not always work.
|
msg4095 |
Author: [hidden] (chichi) |
Date: 2010-07-16 08:22 |
|
Anybody has any idea about this?
Thanks!
|
msg4097 |
Author: [hidden] (ber) |
Date: 2010-07-20 09:12 |
|
Well it just needs to be implemented.
|
msg4099 |
Author: [hidden] (chichi) |
Date: 2010-07-22 08:24 |
|
Yap...:p
|
msg7635 |
Author: [hidden] (rouilj) |
Date: 2022-08-17 02:40 |
|
Bern:
I implemented pretty(self, format="%0.3f").
One thing I didn't expect is that "%0.3f"%True is 1.000.
What should pretty return if the value is None, or can't be represented using the specified
format parameter?
I implemented "" for None and str(self._value) for anything else.
Does that work?
If the format is invalid (e.g. '%0.3') it raises a ValueError and that should
get handled like any other error.
changeset: 6832:234fefd7568a
|
msg7639 |
Author: [hidden] (ber) |
Date: 2022-08-23 07:18 |
|
Hi John,
the original idea was about formatting numbers,
not about boolean or other types.
I think the behavior you have described is good.
Thanks for implementing!
Bernhard
|
|
Date |
User |
Action |
Args |
2022-08-23 13:30:24 | rouilj | set | status: open -> fixed resolution: remind -> fixed |
2022-08-23 07:18:45 | ber | set | messages:
+ msg7639 |
2022-08-17 02:41:21 | rouilj | set | status: pending -> open |
2022-08-17 02:40:07 | rouilj | set | status: new -> pending assignee: rouilj resolution: remind messages:
+ msg7635 nosy:
+ rouilj |
2016-07-04 19:57:09 | rouilj | set | files:
- unnamed |
2016-07-04 19:39:45 | rouilj | set | keywords:
+ Effort-Low |
2010-07-22 08:24:54 | chichi | set | files:
+ unnamed messages:
+ msg4099 |
2010-07-20 09:12:12 | ber | set | messages:
+ msg4097 |
2010-07-16 08:22:22 | chichi | set | messages:
+ msg4095 |
2010-03-08 06:04:23 | chichi | set | nosy:
+ chichi |
2009-07-08 10:44:18 | ber | create | |
|