Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #71557
| References | <mailman.9975.1400000510.18130.python-list@python.org> <5372b2ae$0$29977$c3e8da3$5496439d@news.astraweb.com> <mailman.9994.1400059319.18130.python-list@python.org> <53736acb$0$29977$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2014-05-14 23:17 +1000 |
| Subject | Re: Exception problem with module |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.10005.1400073467.18130.python-list@python.org> (permalink) |
On Wed, May 14, 2014 at 11:08 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote: > One should code as if the next person who reads your program is an easily > upset psychotic axe-murderer who knows where you live. You wouldn't > condone writing y = x.__add__(1) instead of y = x + 1, you shouldn't > condone writing module.__setattr__ directly either. Oddly enough, I was referencing that first half earlier this evening :) There's a difference between x.__add__(1) and x + 1, though. The latter might end up calling (1).__radd__(x), which (obviously) the first won't. I can imagine there might be some use-case where you specifically DON'T want the reflected method to be silently called (maybe for introspection or debugging??). But it falls under code smell, the sort of thing where you absolutely MUST have a comment - like where I have a call to set_foreground(bg), because that could so easily be an error, yet in this case isn't. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Exception problem with module "Joseph L. Casale" <jcasale@activenetwerx.com> - 2014-05-13 16:59 +0000
Re: Exception problem with module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-14 00:02 +0000
RE: Exception problem with module "Joseph L. Casale" <jcasale@activenetwerx.com> - 2014-05-14 09:21 +0000
Re: Exception problem with module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-05-14 13:08 +0000
Re: Exception problem with module Chris Angelico <rosuav@gmail.com> - 2014-05-14 23:17 +1000
RE: Exception problem with module "Joseph L. Casale" <jcasale@activenetwerx.com> - 2014-05-19 23:48 +0000
csiph-web