Message207048
| Author |
ethan.furman |
| Recipients |
ethan.furman |
| Date |
2013年12月28日.19:56:32 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1388260592.79.0.323683192221.issue20092@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
In order to create a coherent integer type class both __int__ and __index__ must be defined or the resulting instances will behave inconsistently in different places.
For example, if __index__ is not defined then the class cannot be used in slices, and if __int__ is not defined then int(integer_type) will fail.
At this point the programmer must remember to define both, but since they should return the same value we can have the type constructor automatically assign __int__ to __index__ when the latter is defined and the former is not. This would be similar to how we currently treat __ne__ when __eq__ is defined. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2013年12月28日 19:56:32 | ethan.furman | set | recipients:
+ ethan.furman |
| 2013年12月28日 19:56:32 | ethan.furman | set | messageid: <1388260592.79.0.323683192221.issue20092@psf.upfronthosting.co.za> |
| 2013年12月28日 19:56:32 | ethan.furman | link | issue20092 messages |
| 2013年12月28日 19:56:32 | ethan.furman | create |
|