[pywin32-checkins] pywin32/com/win32com decimal_23.py,NONE,1.1 readme.htm,1.14,1.15
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2005-05-31 12:36:21
|
Update of /cvsroot/pywin32/pywin32/com/win32com In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24405 Modified Files: readme.htm Added Files: decimal_23.py Log Message: With help from Roger Upole: * Add PyObject_AsCurrency and PyObject_FromCurrency to convert CY/CURRENCY structs to/from Python objects. * Invent a pythoncom.__future_currency__ scheme, allowing us to move from the current brain-dead (hiword, loword) currency support into a decimal.Decimal() object. See win32com\readme.html for more details. --- NEW FILE: decimal_23.py --- # <win32com> # This is a clone of Python 2.4's 'decimal' module. It will only be used when # 'import decimal' fails - so is likely to be used in Python 2.3. # </win32com> # Copyright (c) 2004 Python Software Foundation. # All rights reserved. # Written by Eric Price <eprice at tjhsst.edu> # and Facundo Batista <facundo at taniquetil.com.ar> # and Raymond Hettinger <python at rcn.com> # and Aahz <aahz at pobox.com> # and Tim Peters # This module is currently Py2.3 compatible and should be kept that way # unless a major compelling advantage arises. IOW, 2.3 compatibility is # strongly preferred, but not guaranteed. # Also, this module should be kept in sync with the latest updates of # the IBM specification as it evolves. Those updates will be treated [...3008 lines suppressed...] mantissa = intpart + fracpart tmp = map(int, mantissa) backup = tmp while tmp and tmp[0] == 0: del tmp[0] # It's a zero if not tmp: if backup: return (sign, tuple(backup), exp) return (sign, (0,), exp) mantissa = tuple(tmp) return (sign, mantissa, exp) if __name__ == '__main__': import doctest, sys doctest.testmod(sys.modules[__name__]) Index: readme.htm =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/readme.htm,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** readme.htm 11 Apr 2004 04:41:21 -0000 1.14 --- readme.htm 31 May 2005 12:36:02 -0000 1.15 *************** *** 18,22 **** scripts (and a new <a href="test/readme.txt">readme.txt</a>). Although these are used for testing, they do show a variety of COM techniques.</p> ! <h3>Recent Changes</h3> <h4>win32com.shell</h4> --- 18,57 ---- scripts (and a new <a href="test/readme.txt">readme.txt</a>). Although these are used for testing, they do show a variety of COM techniques.</p> ! ! <a name="currency"><h3>Important Currency changes</h3></a> ! <p> ! In all builds prior to 204, a COM currency value was returned as a tuple of ! integers. Working with 2 integers to represent a currency object was a poor ! choice, but the alternative was never clear. Now Python ships with the ! <a href="http://www.python.org/dev/doc/devel/lib/module-decimal.html">decimal</a> ! module, the alternative has arrived! ! </p> ! <p> ! To ease the transition, from pywin32 build 205 a FutureWarning will be issued ! when your code fetches a COM currency object - but a tuple will still be ! returned. However, if your code sets <code>pythoncom.__future_currency__ = True</code>, ! a warning will not be issued, and a decimal module object will be returned. ! At some undetermined point in the future (but not before build 208) the ! new behaviour will be the default. ! </p> ! <p> ! When supplying a COM currency object, you can supply either a decimal object ! or a tuple. This issue only applies when pythoncom passes you a currency value ! </p> ! <p> ! Python 2.3 does not ship with a decimal module. For this reason, ! win32com/decimal_23.py is supplied with pywin32. This is a clone of the decimal ! module, but will only be used when <code>import decimal</code> fails. If you ! want to use this functionality in your Python 2.3 programs, you should write ! something similar to: ! <pre> ! try: ! import decimal ! except ImportError: ! import win32com.decimal_23 as decimal ! val = decimal.Decimal("123.45") ! </pre> ! </p> ! <h3>Recent Changes</h3> <h4>win32com.shell</h4> *************** *** 27,31 **** These shell interfaces are now generally stable. <h4>New win32com.taskscheduler module</h4> ! Roger Uploe has contribted an interface to the Windows task scheduler. This is actually very neat, and it allows Python to edit the task list as shown by Windows Control Panel. Property page suppport may even appear later, now that the win32 library has the new win32rcparser module. --- 62,66 ---- These shell interfaces are now generally stable. <h4>New win32com.taskscheduler module</h4> ! Roger Upole has contributed an interface to the Windows task scheduler. This is actually very neat, and it allows Python to edit the task list as shown by Windows Control Panel. Property page suppport may even appear later, now that the win32 library has the new win32rcparser module. |