Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83269 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2015-01-07 00:35 +1100 |
| Last post | 2015-01-07 00:35 +1100 |
| 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: Comparisons and sorting of a numeric class.... Chris Angelico <rosuav@gmail.com> - 2015-01-07 00:35 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2015-01-07 00:35 +1100 |
| Subject | Re: Comparisons and sorting of a numeric class.... |
| Message-ID | <mailman.17414.1420551359.18130.python-list@python.org> |
On Wed, Jan 7, 2015 at 12:30 AM, Andrew Robinson <andrew3@r3dsolutions.com> wrote: > Why this is so important to Guido, I don't know ... but it's making it VERY > difficult to add named aliases of False which will still be detected as > False and type-checkable as a bool. If my objects don't type check right -- > they will likely break some people's legacy code... and I really don't even > care to create a new instance of the bool object in memory which is what > Guido seems worried about, rather I'm really only after the ability to > detect the subclass wrapper name as distinct from bool False or bool True > with the 'is' operator. If there were a way to get the typecheck to match, > I wouldn't mind making a totally separate class which returned the False > instance; eg: something like an example I modified from searching on the > web: Okay, so why not just go with your own class, and deal with the question of the type check? Simple solution: Instead of fiddling with __gt__/__lt__, create your own method, and use your own comparison function to sort these things. ChrisA
Back to top | Article view | comp.lang.python
csiph-web