Message122453
| Author |
mark.dickinson |
| Recipients |
gumtree, mark.dickinson, meador.inge |
| Date |
2010年11月26日.13:12:33 |
| SpamBayes Score |
0.00016970516 |
| Marked as misclassified |
No |
| Message-id |
<1290777155.61.0.573607722281.issue5211@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
I think that's expected behaviour. Note that int vs float behaves in the same way as float vs complex:
>>> class xint(int):
... def __radd__(self, other):
... print "__radd__"
... return 42
...
>>> 3 + xint(5)
__radd__
42
>>> 3.0 + xint(5) # xint.__radd__ not called.
8.0
As with your example, the float.__add__ method is happy to deal with an int or an instance of any subclass of int. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2010年11月26日 13:12:35 | mark.dickinson | set | recipients:
+ mark.dickinson, gumtree, meador.inge |
| 2010年11月26日 13:12:35 | mark.dickinson | set | messageid: <1290777155.61.0.573607722281.issue5211@psf.upfronthosting.co.za> |
| 2010年11月26日 13:12:33 | mark.dickinson | link | issue5211 messages |
| 2010年11月26日 13:12:33 | mark.dickinson | create |
|