[issue2706] datetime: define division timedelta/timedelta

Jess Austin report at bugs.python.org
Wed Mar 25 01:04:24 CET 2009


Jess Austin <jess.austin at gmail.com> added the comment:

A comment on the two most recent patches...  For both of these, we can
do the following:

>>> from datetime import timedelta
>>> td = timedelta(12)
>>> td
datetime.timedelta(12)
>>> td //= 3
>>> td
datetime.timedelta(4)
>>> td //= timedelta(2)
>>> td
2          # CHANGED VARIABLE TYPE!

I think the last operation will trap unsuspecting programmers, and
provide no benefit for the savvy.  There really is no reason to allow an
in-place operation like this to change the type of the variable so
drastically.  (That is, I realize a similar thing could happen with ints
and floats, but it seems worse with timedeltas and ints.)  I feel the
last operation should raise a TypeError, even though it would be quite
valid for a non-in-place operation.

----------
nosy: +jess.austin

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2706>
_______________________________________


More information about the Python-bugs-list mailing list