消息 [84131]
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. |
|
| 日期 |
用户 |
动作 |
参数 |
| 2009-03-25 00:04:25 | jess.austin | 修改 | recipients:
+ jess.austin, jribbens, amaury.forgeotdarc, mark.dickinson, belopolsky, vstinner, fredrikj, webograph, tleeuwenburg@gmail.com |
| 2009-03-25 00:04:24 | jess.austin | 修改 | messageid: <1237939464.57.0.053130167769.issue2706@psf.upfronthosting.co.za> |
| 2009-03-25 00:04:23 | jess.austin | 链接 | issue2706 messages |
| 2009-03-25 00:04:23 | jess.austin | 创建 | |
|