Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.06; 'plenty': 0.07; 'except:': 0.09; 'lawrence': 0.09; 'try:': 0.09; 'url:blog': 0.10; 'def': 0.12; 'jan': 0.12; 'suggest': 0.14; 'csv': 0.16; 'systemexit': 0.16; 'think?': 0.16; 'exception': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'earlier': 0.24; 'guys': 0.24; "i've": 0.25; 'purposes': 0.26; 'least': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'getting': 0.31; 'chase': 0.31; 'quite': 0.32; 'url:python': 0.33; 'trouble': 0.34; 'agree': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'should': 0.36; 'clear': 0.37; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'read': 0.60; 'most': 0.60; 'today': 0.64; 'subject:The': 0.64; 'here': 0.66; '10:32': 0.84; '2015': 0.84; 'bare': 0.84; 'partially': 0.84; 'rubbish': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=/dnCjzbA0+OBsIE1lgzxcPRe5RxSlM22CR7J5tyisTs=; b=QTlZuYYbSeG38YlahROzZ9Og4cHJOXvzIg+CdfZirwKpv71WjiASeDpsC9WlZ7LHot Za1aSxXnkvt8iZzxnyphzrrkm2sTglYwlz5EoUqsbpt8ThvpLwOtYprxXhAT81AppmsW p/FyyvA+9T6vd5RW4XHoFRuN7QbfjjDk9OsNoOIVaGTvjE1DlMnBOgrgdzmE9Zr67+rO ye22apUs8K5l1jIDk/jfM6IFd1F3zH1EfUIgf5Us0BDID0vzgXd3h56h0Hz5GIcsLt1Y 041FkMFbnhfP035XB3KZOeaINLnsHnkqq3K/wDkHorhE4FEU9lKJ09NIP5WH6PuwwWwQ 3bqw== X-Received: by 10.66.148.161 with SMTP id tt1mr4161987pab.85.1422571928785; Thu, 29 Jan 2015 14:52:08 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <20150129113238.7eaa986d@bigbox.christie.dr> References: <20150129113238.7eaa986d@bigbox.christie.dr> From: Ian Kelly Date: Thu, 29 Jan 2015 15:51:28 -0700 Subject: Re: The Most Diabolical Python Antipattern To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1422571931 news.xs4all.nl 2874 [2001:888:2000:d::a6]:48271 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:84852 On Thu, Jan 29, 2015 at 10:32 AM, Tim Chase 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?