Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #6760 > unrolled thread
| Started by | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| First post | 2011-05-31 15:18 -0700 |
| Last post | 2011-05-31 15:18 -0700 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: returning NotImplemented Ethan Furman <ethan@stoneleaf.us> - 2011-05-31 15:18 -0700
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2011-05-31 15:18 -0700 |
| Subject | Re: returning NotImplemented |
| Message-ID | <mailman.2338.1306879538.9059.python-list@python.org> |
Eric Snow wrote: > Looking at the ABC code [1], I noticed that Mapping's __eq__ method can > return NotImplemented. This got me curious as to why you would return > NotImplemented and not raise a TypeError or a NotImplementedError. My understanding is that if your object does not know how to perform the desired action you should return NotImplemented; Python will then give the other object a chance to perform the operation (after all, it may know how), and if the other object also returns NotImplemented then Python itself will raise a TypeError. If the first object were to raise TypeError (or any exception), the second object would not get the chance to try. ~Ethan~
Back to top | Article view | comp.lang.python
csiph-web