prePEP: Money data type
FBatista at uniFON.com.ar
Mon Oct 20 23:11:09 CEST 2003
Alex Martelli wrote:
#- > There're so many ways, that maybe the best solution is to just let
#- > everybody to subclass Money and redefine __str__. The
#- problem is that
#- > decimalSeparator and thousandSeparator are important to
#- parse the string
#- > in the constructor.
#- Ah, that's input, not _necessarily_ connected to output; see the
#- suggestion in my other post about using locale.localeconv().
Not necessarily conected, that's right.
But seems right to me that if your decimal separator is, i.e., '&', you get
something like this:
>>> class MyMoney(Money):
decimalSeparator = '&'
>>> m = MyMoney('34&2', 3)
>>> print m
>>> print float(m)
More information about the Python-list