A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039119.html below:

[Python-Dev] prePEP: Money data type

[Python-Dev] prePEP: Money data typeBatista, Facundo FBatista at uniFON.com.ar
Mon Oct 20 16:54:55 EDT 2003
#- Sure, rounding IS best set by function, though you may want more than
#- two (roundForbid to raise exceptions when rounding tries to happen,
#- roundTruncate, etc).

So far, goes 4 different kind:
	roundPlain
	roundBanker
	roundTruncate
	roundForbid


#- class Money:
#-     round = staticmethod(roundWhateverDefault)
#-     precision = someDefaultPrecision
#-     def __init__(self, value, precision=None, round=None):
#-         self.value = value
#-         if precision is not None: self.precision = precision
#-         if round is not None: self.round = round
#- 
#- then use self.precision and self.round in all further 
#- methods -- they'll
#- correctly go to either the INSTANCE attribute, if 
#- specifically set, or
#- the CLASS attribute, if no instance attribute is set.  A 
#- useful part of
#- how Python works, btw.

Wow! This is the difference between a python newbie and a python guru, :)


#- I do NOT think any advanced formatting should be part of the 
#- responsibilities
#- of class Money itself.  I would focus on correct and 
#- complete arithmetic with
#- good handling of exact precision and rounding rules: I 
#- contend THAT is the
#- really necessary part.

Triming formatting, adding different types of rounding, and allowing strings
with engineering notation. Maybe is better to build a Decimal class (kind of
FixedPoint) easily subclassable to make a Money one.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4