Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #83278
| Date | 2015-01-06 18:53 -0800 |
|---|---|
| From | Andrew Robinson <andrew3@r3dsolutions.com> |
| Subject | Re: Comparisons and sorting of a numeric class.... |
| References | (1 earlier) <54ABC52A.1050507@davea.name> <54ABE383.3020801@r3dsolutions.com> <54ABEAD9.8070000@davea.name> <54AC938C.7040206@r3dsolutions.com> <m8i60t$fp3$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.17428.1420599294.18130.python-list@python.org> (permalink) |
On 01/06/2015 06:34 PM, Terry Reedy wrote: > On 1/6/2015 9:01 PM, Andrew Robinson wrote: > > [snip] > > There are very few (about 4) builtin classes that cannot be > subclassed. bool is one of those few, float is not. Go ahead and > subclass it. > > >>> class F(float): pass > > >>> F > <class '__main__.F'> > >>> F(2.3) + F(3.3) > 5.6 > > Thanks terry! That's a relief. Ive just managed to find a few classes that won't subtype by trial and error in the last two months and was getting pessimistic. ( eg: doing web pages I wanted to customize the error output traceback stack from a python script based on where the exception occurred..... UUUUGH! I worked around the no sub-typing issue, but it took a lot of guessing to trick python into accepting a fake class to the print traceback functions the webserver used... )
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Comparisons and sorting of a numeric class.... Andrew Robinson <andrew3@r3dsolutions.com> - 2015-01-06 18:53 -0800
csiph-web