prePEP: Money data type

Batista, Facundo FBatista at uniFON.com.ar
Mon Oct 20 17:11:09 EDT 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
$34&200
>>> print float(m)
34.200000000000003


.	Facundo





More information about the Python-list mailing list