[Pymoney-general] An attempt of implementation.
Brought to you by:
facundobatista
From: Darek S. <ds...@us...> - 2005-05-15 20:52:32
|
Hi, I'm sending two files, which are an attempt to implement my current understanding of the PEP. They're not finished (Currency.distrib and DefaultContext.distrib methods are still to be written, I also need to add more tests) and I'm not really sure that all of those if context is None: context = getcontext() checks in almost all of Currency methods are needed, but the PEP clearly says that "Definitely the idea is not to get a context per Currency value.". Hm, I'm not sure, perhaps changing it to something like def __add__(self, other, context=None): """ Returns self + other. """ result = Currency(Decimal.__add__(self,other,context or getcontext())) return context._round_to_dec_quant(result) would be better? I haven't also touched ISO-4217 and/or ISO-3166 tables at all, because it's still unclear how should they look like. I'm not an threading guy, so getcontext() and setcontext() methods should be taken special care of (though I simply copy&pasted them from decimal module). Anyway, it's an attempt, I hope it will be useful, but feel free to tell me it's a crappy code :-) darek PS. I'm not submitting it to the sf.net patch tracker, should I? |