datetime.timedelta division confusion

skip at pobox.com skip at pobox.com
Sat Sep 1 14:28:02 EDT 2007


Running from Subversion, I see confusing (to me) behavior related to
division of datetime.timedelta objects by integers:

    % python
    Python 2.6a0 (trunk:57277:57280M, Aug 28 2007, 17:44:49) 
    [GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import datetime
    >>> d = datetime.timedelta(1)
    >>> d / 2
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: unsupported operand type(s) for /: 'datetime.timedelta' and 'int'
    >>> d.__div__(2)
    datetime.timedelta(0, 43200)

When I run the interpreter under gdb's control with a breakpoint set in
delta_divide, the breakpoint is not reached in the first case, but it is in
the second.  Is there something amiss with division of timedelta objects by
ints or am I just missing something?

Skip




More information about the Python-list mailing list