Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #84852
| References | <madpuv$he7$1@ger.gmane.org> <20150129113238.7eaa986d@bigbox.christie.dr> |
|---|---|
| From | Ian Kelly <ian.g.kelly@gmail.com> |
| Date | 2015-01-29 15:51 -0700 |
| Subject | Re: The Most Diabolical Python Antipattern |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.18286.1422571931.18130.python-list@python.org> (permalink) |
On Thu, Jan 29, 2015 at 10:32 AM, Tim Chase <python.list@tim.thechases.com> wrote: > On 2015-01-29 17:17, Mark Lawrence wrote: >> The author is quite clear on his views here >> https://realpython.com/blog/python/the-most-diabolical-python-antipattern/ >> but what do you guys and gals think? > > I just read that earlier today and agree for the most part. The only > exception (pun only partially intended) I've found is in functions > that need to return a defined type. I have one that I call int0() > that is my "give me a freakin' int" function which is something like > > def int0(val): > try: > return int(val) > except: > return 0 > > because I deal with a lot of CSV data from client/vendor that has > blanks, "NULL", "---", and plenty of other rubbish to suggest > something that, for my purposes is really just a 0. > > Yes, I've been stung by it occasionally, but it's not much trouble to > see that I'm getting a 0 some place that should have a value I need > to extract. At least use "except Exception" instead of a bare except. Do you really want things like SystemExit and KeyboardInterrupt to get turned into 0?
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-29 15:51 -0700
Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 08:16 +0200
Re: The Most Diabolical Python Antipattern Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-30 08:10 +0000
Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 11:02 +0200
Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 02:17 -0700
Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 12:00 +0200
Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 08:21 -0700
Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 17:30 +0200
Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 08:42 -0700
Re: The Most Diabolical Python Antipattern Marko Rauhamaa <marko@pacujo.net> - 2015-01-30 17:56 +0200
Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 09:38 -0700
Re: The Most Diabolical Python Antipattern Chris Angelico <rosuav@gmail.com> - 2015-01-31 02:55 +1100
Re: The Most Diabolical Python Antipattern Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-30 02:11 -0700
Re: The Most Diabolical Python Antipattern Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-31 01:28 +0000
csiph-web