diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-04-03 15:54:36 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-04-03 15:54:36 (GMT) |
commit | c593577a4a90b9c806c744b151efcb4e6b052aa4 (patch) | |
tree | c88828d3c2cb1fd0925f2058cfaf3063edd289c2 /Doc/library/struct.rst | |
parent | 089b00cbc3006fa60fe71f64341e38b83cc4498d (diff) | |
download | cpython-c593577a4a90b9c806c744b151efcb4e6b052aa4.zip cpython-c593577a4a90b9c806c744b151efcb4e6b052aa4.tar.gz cpython-c593577a4a90b9c806c744b151efcb4e6b052aa4.tar.bz2 |
Merged revisions 79674 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r79674 | mark.dickinson | 2010-04-03 15:05:10 +0100 (Sat, 03 Apr 2010) | 3 lines
Issue #8300: Let struct.pack use __index__ to convert and pack non-integers.
Based on a patch by Meador Inge.
........
Diffstat (limited to 'Doc/library/struct.rst')
-rw-r--r-- | Doc/library/struct.rst | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Doc/library/struct.rst b/Doc/library/struct.rst index bee154f..ee949d9 100644 --- a/Doc/library/struct.rst +++ b/Doc/library/struct.rst @@ -119,6 +119,15 @@ Notes: the platform C compiler supports C :ctype:`long long`, or, on Windows, :ctype:`__int64`. They are always available in standard modes. +(4) + When attempting to pack a non-integer using any of the integer conversion + codes, if the non-integer has a :meth:`__index__` method then that method is + called to convert the argument to an integer before packing. + + .. versionchanged:: 3.2 + Use of the :meth:`__index__` method for non-integers is new in 3.2. + + A format character may be preceded by an integral repeat count. For example, the format string ``'4h'`` means exactly the same as ``'hhhh'``. |